/* Desktop and laptop browsers: a mouse or trackpad is the main pointer. index.html links this file
   with media="(hover: hover) and (pointer: fine)", so phones and tablets never wait for it.
   Vite copies it as it is (no bundling, no @import): plain CSS, with native nesting.
   Rules are nested in :root, which outranks the phone rules they change whatever order the two
   stylesheets load in (Vite puts the app's own stylesheet after this one); the big-screen layout
   sits inside media and @supports queries as well. @supports selector(&) keeps browsers that
   can't parse nesting on the phone layout, instead of tokens without the rules that use them.
   Rules that start with a type selector take a leading &: browsers with the 2023 nesting syntax
   drop a nested rule that starts with a type selector, and & works in all of them. */

:root {
  /* Mouse feel: hover and pressed states, only on buttons that do something. */
  .link:hover {
    color: var(--ink);
  }
  .go:not(.danger):hover,
  .cell.next:hover {
    background: color-mix(in srgb, var(--ink) 86%, var(--dim));
  }
  & button.tile:not(.locked):hover,
  & button.cell:not(.locked, .next):hover,
  & button.course-card:not(.locked):hover,
  & button.daily-card:hover,
  & button.day:not(.today):hover {
    border-color: var(--dim);
  }

  /* Steady digits: counts that change while typing don't jitter. */
  .status,
  .cc-count,
  .cell .note,
  .bands .count,
  .day .note {
    font-variant-numeric: tabular-nums;
  }
}

/* Pressed movement is off under reduced motion, so the override doesn't have to outrank the rules. */
@media (prefers-reduced-motion: no-preference) {
  :root {
    .go:active,
    & button.tile:not(.locked):active,
    & button.cell:not(.locked):active,
    & button.course-card:not(.locked):active,
    & button.daily-card:active,
    & button.day:active {
      transform: translateY(1px);
    }
  }
}

/* The big-screen layout: windows with room for it (WIDE_ROOM in src/platform/wide.ts). One centred
   920 px column on every screen, so the top bar sits in the same place everywhere. */
@media (min-width: 900px) and (min-height: 560px) {
  @supports selector(&) {
    /* Sizes grow with the window, both ways (a short window shrinks them), up to about 1440 × 900;
       bigger windows get wider margins. html:root outranks tokens.css's :root. */
    html:root {
      --page-max: 920px;
      --gutter: 40px;
      --text-row: clamp(21px, min(1.9vw, 3.3vh), 28px);
      --text-entry: clamp(32px, min(3.2vw, 5.4vh), 48px);
      --text-sm: clamp(15px, min(1.2vw, 2vh), 17px);
      --text-body: clamp(18px, min(1.45vw, 2.4vh), 21px);
      --text-title: clamp(26px, min(2.4vw, 4vh), 34px);
      --row-h: calc(var(--text-row) * 1.85);
      --button-h: 58px;
    }

    :root {
      & body {
        font-size: 18px;
      }
      #app {
        padding-top: clamp(16px, 3.5vh, 36px);
      }
      .top {
        min-height: 52px;
      }
      .body {
        max-width: none;
      }
      .body.dim {
        font-size: var(--text-sm);
      }
      .go {
        font-size: 18px;
      }

      /* The menu and the results centre in the window. The lesson card and notices keep their top
         bar at the top and centre the rest below it. Levels, lists and Daily start at the top. */
      .menu,
      .finish,
      .daily-done {
        justify-content: center;
        padding-bottom: 6vh;
      }
      .lesson,
      .notice {
        padding-bottom: 6vh;
      }
      .lesson > .top + *,
      .notice > .top + * {
        margin-top: auto;
      }
      .lesson > :last-child,
      .notice > :last-child {
        margin-bottom: auto;
      }
      .menu .spacer,
      .lesson .spacer,
      .finish .spacer,
      .daily-done .spacer {
        display: none;
      }

      /* Menu: one block, centred. */
      .menu {
        align-items: center;
        text-align: center;
      }
      .menu .title {
        margin: 0 0 clamp(12px, 2.5vh, 24px);
        font-size: clamp(96px, min(11.5vw, 18.5vh), 176px);
      }
      .menu .tagline {
        margin: 0 0 clamp(28px, 6vh, 56px);
        font-size: clamp(18px, min(1.55vw, 2.6vh), 23px);
      }
      .menu .actions.stack {
        width: clamp(380px, 33vw, 480px);
        max-width: none;
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        margin: 0;
      }
      .menu .links {
        margin-top: 10px;
      }
      .daily-card {
        min-height: 66px;
        padding: 12px 20px;
        font-size: 18px;
      }
      .play {
        min-height: 76px;
        font-size: 20px;
      }
      .play .sub {
        font-size: 15px;
      }

      /* Lesson card: larger reading type keeps lines under about 80 characters across the column. */
      .lesson .glyph {
        margin-bottom: clamp(16px, 3vh, 28px);
        font-size: clamp(88px, min(9vw, 16vh), 150px);
      }
      .lesson .body {
        font-size: clamp(19px, min(1.6vw, 2.7vh), 23px);
      }
      .lesson .ex .pat {
        font-size: 19px;
      }
      .lesson .ex .s {
        font-size: 22px;
      }
      .lesson .actions.stack {
        justify-content: flex-start;
        margin-top: 32px;
      }
      .lesson .actions .go {
        min-width: 240px;
      }

      /* Level, hole, daily puzzle. */
      .entry-block {
        margin-top: clamp(8px, 2.5vh, 24px);
      }
      .entry {
        padding-bottom: 12px;
      }
      .entry:focus-within {
        padding-bottom: 10px;
      }
      .status {
        margin-top: 10px;
      }
      .groups {
        --col-gap: 28px;
        margin-top: 4px;
      }
      .groups h2 {
        margin-top: clamp(14px, 3vh, 28px);
      }
      .row {
        gap: 14px;
      }
      .dot {
        width: 13px;
        height: 13px;
      }
      .level .actions,
      .level .actions .go {
        min-height: 56px;
      }
      .reads {
        margin-top: 24px;
        font-size: 16px;
      }

      /* Lists: courses 2 × 2, the tutorial's levels six to a row, a course's holes and its
         scorecard one row of nine, like a golf scorecard. */
      .course-cards {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 16px;
        margin-top: 20px;
      }
      .course-card {
        justify-content: space-between;
        min-height: 120px;
        padding: 20px 22px;
        font-size: 20px;
      }
      .level-tiles {
        grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
        gap: 12px;
        margin-top: 20px;
      }
      .level-tiles .cell {
        min-height: 92px;
        padding: 12px;
      }
      .cell .n,
      .cell .g {
        font-size: 14px;
      }
      .cell .note {
        font-size: 20px;
      }
      .course .level-tiles,
      .finish .cells {
        grid-template-columns: repeat(9, minmax(0, 1fr));
        gap: 10px;
      }
      .course .level-tiles .cell {
        min-height: 100px;
      }
      .finish .cells .cell {
        min-height: 84px;
        padding: 10px;
      }
      .finish .actions.stack,
      .daily-done .actions.stack {
        justify-content: flex-start;
        margin-top: 32px;
      }

      /* Daily screen: a month fits a 720 px window. */
      .bands {
        max-width: 620px;
      }
      .bar {
        height: 12px;
      }
      .cal-head h2 {
        font-size: var(--text-title);
      }
      .calendar,
      .cal-days {
        gap: clamp(4px, 0.8vh, 8px);
      }
      .cal-days {
        font-size: 14px;
      }
      .day {
        min-height: clamp(48px, 7.5vh, 76px);
        padding: 8px;
      }
      .day .d,
      .day .note {
        font-size: 14px;
      }
      .day.today {
        padding: 7px;
      }

      /* Dialogs: a card over the dimmed page. A click on the page closes it (src/ui/sheet.ts). */
      .sheet {
        display: grid;
        place-items: center;
        padding: 5vh 24px;
        background: rgb(24 33 43 / 0.32);

        @media (prefers-color-scheme: dark) {
          background: rgb(0 0 0 / 0.5);
        }
      }
      .sheet-in {
        width: min(680px, 100%);
        max-width: none;
        max-height: 90vh;
        margin: 0;
        overflow: auto;
        padding: 20px 36px 36px;
        border-radius: 12px;
        background: var(--bg);
        box-shadow: 0 24px 72px rgb(24 33 43 / 0.28);

        @media (prefers-color-scheme: dark) {
          border: 1px solid var(--line);
          box-shadow: 0 24px 72px rgb(0 0 0 / 0.5);
        }
      }
    }
  }
}
