/* What a person chooses in Settings under "Appearance and accessibility": text size, motion and
 * words beside icons. They are set as attributes on <html> by js/prefs-init.js (before first paint)
 * and js/prefs.js, so this file is only ever selectors on those attributes. Additive: it adds
 * rules and does not rewrite the layout css.
 */

/* ---- text size ----
 *
 * The page is scaled with CSS zoom rather than by changing font sizes one by one. The app is drawn
 * in pixels throughout, so a root font size would move nothing, and a per-rule scale would be a
 * promise broken by the next rule added. Zoom grows every label, button, gap and icon together and
 * keeps the proportions, which is what "nothing gets tiny" asks for. Media queries still read the
 * real window, so a phone keeps its phone layout, and the scale on a phone is kept smaller because
 * there is less room to grow into.
 *
 * It is set on <body>, not on <html>. Zoom on the root element makes window.innerWidth larger than
 * the screen, and everything fixed to the window (the phone's bottom bar, the dialogs) is then
 * sized to a window wider than the one there is, and runs off the edge. On the body the window is
 * left alone. The one thing that still needs saying is the app's minimum height, which is "the
 * window" and has to be divided by the same factor to remain "the window". */
html[data-text-size="large"] { --text-zoom: 1.125; }
html[data-text-size="larger"] { --text-zoom: 1.25; }
@media (max-width: 640px) {
  html[data-text-size="large"] { --text-zoom: 1.08; }
  html[data-text-size="larger"] { --text-zoom: 1.16; }
}
html[data-text-size] body { zoom: var(--text-zoom); }
html[data-text-size] #app { min-height: calc(100vh / var(--text-zoom)); min-height: calc(100dvh / var(--text-zoom)); }

/* What is fixed to the window is told the window's size in the page's own (zoomed) units, so it is
   exactly as wide and as tall as the screen: the dialogs and sign-in screens, the phone's bottom
   bar, and the phone's sheets. */
html[data-text-size] .modal,
html[data-text-size] #boot,
html[data-text-size] #auth,
html[data-text-size] #onboarding {
  right: auto; bottom: auto;
  width: calc(100vw / var(--text-zoom));
  height: calc(100vh / var(--text-zoom)); height: calc(100dvh / var(--text-zoom));
}
html[data-text-size] #bottom-nav { right: auto; width: calc(100vw / var(--text-zoom)); }

/* Anything sized as a share of the window's height needs the same division, or it comes out taller
   than the window by the zoom: a dialog's top would be off the screen, with its title. */
html[data-text-size] .modal-box {
  max-height: calc((100vh - 40px) / var(--text-zoom)); max-height: calc((100dvh - 40px) / var(--text-zoom));
}
html[data-text-size] .section-nav { max-height: calc((100vh - 128px) / var(--text-zoom)); }
@media (max-width: 640px) {
  html[data-text-size] .modal-box { max-height: calc(92dvh / var(--text-zoom)); }
}
@media (max-width: 640px) {
  html[data-text-size] #more-sheet { right: auto; width: calc(100vw / var(--text-zoom) - 16px); }
}

/* ---- motion ----
 *
 * app.css already stops animation for a device that asks (prefers-reduced-motion), unless the
 * person has chosen "full" here. This is the other half: a person who asked for less here gets it
 * on a device that did not. */
html[data-motion="reduce"] *,
html[data-motion="reduce"] *::before,
html[data-motion="reduce"] *::after {
  animation-duration: .01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: .01ms !important;
  scroll-behavior: auto !important;
}

/* ---- words beside icons ----
 *
 * An icon-only button also shows its own name. Three shapes of icon-only button exist: one with a
 * visually hidden label inside it (.sr-only), one named by aria-label, and one named by title.
 * Each shows what it already carries, so nothing is written twice and no button is named
 * differently on screen than to a screen reader. */
html[data-icon-labels="on"] .icon-btn {
  width: auto; min-width: 40px; padding: 0 var(--space-16); gap: var(--space-8); border-radius: var(--radius-pill);
  font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap;
}
html[data-icon-labels="on"] .icon-btn .sr-only {
  position: static; width: auto; height: auto; margin: 0; overflow: visible; clip: auto; white-space: nowrap;
}
html[data-icon-labels="on"] .icon-btn[aria-label]:not(:has(.sr-only))::after { content: attr(aria-label); }
html[data-icon-labels="on"] .icon-btn[title]:not([aria-label]):not(:has(.sr-only))::after { content: attr(title); }

/* Ceremony: with words beside them, the move and edit buttons are too wide to share a line with the item on a
   phone, so they take a line of their own under it. */
html[data-icon-labels="on"] .cer-row { flex-wrap: wrap; }
html[data-icon-labels="on"] .cer-row > .row-actions { flex: 1 1 100%; flex-wrap: wrap; justify-content: flex-end; }
/* Settings, Parts of the day: the same, for the move and edit buttons beside each part. */
html[data-icon-labels="on"] .part-row { flex-wrap: wrap; }
html[data-icon-labels="on"] .part-row > .part-name { flex-basis: calc(100% - var(--space-32)) !important; }

/* Compact list rows on a phone (css/app.css): with words beside them, the row's edit button is too wide to sit beside
   the name, so it takes its own line at the end of the row. */
@media (max-width: 640px) {
  html[data-icon-labels="on"] table.data tbody tr:not(.group-row) > td.actions { position: static; display: flex; width: auto; margin-top: var(--space-8); }
  html[data-icon-labels="on"] table.data tbody tr:not(.group-row) > td.cell-primary { padding-right: 0 !important; }
}
