/* ============================================================================
   55-home-fit.css - v0.24.0.0: THE BOARD IS ONE SCREEN.

   Owner, on the timeline preview: the main section with the input and the task
   generator did not fit the screen, and the home page should have no scrollbar.
   So the board is a viewport layout now: the top bar, the horizon tabs, the
   calendar and the compose bar always fit one screen, and the task card takes
   whatever height is left and scrolls INSIDE itself (.tasks-scroll in Home.razor),
   in the list and in the timeline alike. The compose bar is always on screen.

   SCOPED TO THE BOARD. Every selector starts at .home-fit, the class on Home's own
   .chronos-root, or at the layout shell that holds it. /pit, /friends, /store, the
   public card, the studio and the email gate's copy of the board keep their normal
   document scroll (HomeFitLayoutTests pins the scope).

   THE SLACK LIVES IN THE CARD. The owner once rejected a layout where an empty 1fr
   row opened a huge band between a sparse board and the compose bar (00-tokens-base,
   .chronos-root). Here nothing opens between the blocks: the card itself is the
   flexible part, and an empty card centres its own placeholder.

   NOTHING CLIPS, NOTHING JUMPS. No overflow: hidden on the shell or the root: the
   top-bar popovers hang over the board, and a screen too short for the floors below
   (a phone on its side) scrolls the page as before instead of cutting the compose
   bar off. Widths are untouched, so html's scrollbar-gutter keeps doing its job.
   ============================================================================ */

/* ---- 1. the shell and the root ---------------------------------------------------------------- */

/* One screen tall. 100dvh follows a phone's collapsing address bar; 100vh is the fallback for a
   browser without dynamic units. The shell's base min-height: 100vh is the LARGE viewport on a phone
   (address bar hidden), which would push the compose bar under the bar while it shows, hence 0. */
.chronos-shell:has(> .home-fit) {
    height: 100vh;
    height: 100dvh;
    min-height: 0;
}

/* A flex column instead of the base grid: the /design arrange order (41-arrange.css) can move the
   four slots, and only a flex item can take the slack wherever it lands. The bottom padding keeps a
   phone's home indicator off the compose bar. */
.chronos-root.home-fit {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    padding-bottom: max(14px, env(safe-area-inset-bottom, 0px));
}

.home-fit > .topbar,
.home-fit > .horizon-tabs,
.home-fit > .compose-bar {
    flex: none;
}

/* The build line rides the layout shell under every page. Under the board it pushed the compose bar
   up by a line the task card needs more: on a phone, and on a 1366x768 laptop, where its 27px were
   most of what the hour box lacked. It stays on every other page. */
.chronos-shell:has(> .home-fit) > .app-version {
    display: none;
}

/* The main area takes what the fixed slots leave. Its own minimum stays content-based: the calendar
   plus the task card's floors, so a window too short for those scrolls instead of overlapping. */
.home-fit > .main-area {
    flex: 1 1 auto;
}

/* ---- 2. the task card --------------------------------------------------------------------------- */

/* The scroll region between the progress row and the completed taskbar.
   contain: size is load-bearing: without it the region's content (a full board, a 24 hour axis)
   would count towards the card's minimum height and push the page past the screen again. The floor
   keeps a readable slice on a short screen; below it the page scrolls rather than drawing a slit.
   overflow-x: hidden because the urgent Main card scales by 3% and must not open a sideways bar.

   THE EDGES ARE SOFT. A clipping region cut the Main card's halo into a hard lavender shelf under
   the progress row, and cut scrolled cards with a ruler. The mask fades the top 10px and the bottom
   8px instead: the halo dies out before the edge, and a card leaving the region dissolves rather
   than being sliced. The top padding keeps the card's badge clear of the fade, and every board
   branch keeps at least 8px of padding at its foot, so nothing that should be crisp sits in it. */
.home-fit .tasks-scroll {
    flex: 1 1 0;
    min-height: 140px;
    display: flex;
    flex-direction: column;
    padding-top: 10px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    contain: size;
    scrollbar-width: thin;
    -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 10px, #000 calc(100% - 8px), transparent 100%);
    mask-image: linear-gradient(to bottom, transparent 0, #000 10px, #000 calc(100% - 8px), transparent 100%);
}

/* The urgent Main card breathes by scale(1.03) (06-planning-tasks.css). Edge to edge inside a
   clipping region, its borders were shaved off at every peak - an edge that flickers. 1.6% a side is
   more than the 1.5% the scale reaches, at any card width. */
.home-fit .tasks-scroll > .main-task {
    flex: none;
    margin-inline: max(6px, 1.6%);
}

/* A grid taller than its rows stretches them, so two tasks on a tall card would become two huge
   tiles. The rows keep their own height and the card's slack stays below them, inside the card. */
.home-fit .task-cols {
    flex: 1 0 auto;
    align-content: start;
}

.home-fit .board-empty {
    flex: 1 0 auto;
}

/* ---- 3. the timeline fills the card ------------------------------------------------------------- */

/* On the board the hour box is no longer a fixed --tl-height: it takes the card's remaining height,
   under the Main card, the header and the deadline strip. The floor is two and a bit hours; a card
   with less room than that scrolls its region instead (the studio keeps the fixed box). */
.home-fit .board-timeline {
    flex: 1 0 auto;
    display: flex;
    flex-direction: column;
}

.home-fit .board-timeline > .tl {
    flex: 1 1 auto;
    min-height: 0;
}

.home-fit .tl-scroll {
    flex: 1 1 0;
    height: auto;
    min-height: 128px;
}

/* The Main card stays on top of the timeline as a compact strip: the badge, the checkbox, the title
   and the deadline. The description, labels, progress and steps fold away here and stay one tap
   away in the detail modal; the list view still shows the full card. */
.home-fit .tasks-scroll.is-timeline .main-task {
    padding: 9px 14px;
    margin-block: 12px 6px;
}

.home-fit .tasks-scroll.is-timeline .main-task .main-task-head {
    align-items: center;
}

.home-fit .tasks-scroll.is-timeline .main-task .main-task-title {
    overflow: hidden;
    font-size: 15px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.home-fit .tasks-scroll.is-timeline .main-task .main-task-desc,
.home-fit .tasks-scroll.is-timeline .main-task .task-labels,
.home-fit .tasks-scroll.is-timeline .main-task .bar-row,
.home-fit .tasks-scroll.is-timeline .main-task .main-task-subs,
.home-fit .tasks-scroll.is-timeline .main-task .task-json-copy {
    display: none;
}

/* ---- 4. stacked panels (980px and below): phones and tablets ------------------------------------- */

@media (max-width: 980px) {
    /* 02-main-layout.css pins .tasks to its content height here (flex: 0 0 auto) so a stacked card
       never grows. On the board the card is exactly what should grow, and this selector out-specifies
       that rule (0,3,0 against 0,2,0). */
    .home-fit > .main-area > .tasks {
        flex: 1 1 auto;
    }

    .home-fit > .main-area {
        gap: 10px;
    }

    /* ONE WEEK on a stacked board, tablets included. A phone already shows only the active week
       (02-main-layout.css, the 720px block); between 721 and 980px the full six-row month sat above
       the task card and left it a 250px slit on a 768x1024 tablet. Same rule, same polarity: the
       class marks the rows that are hidden, and CalendarGrid decides which row is active. */
    .home-fit .cal-grid .calday.cal-week-inactive {
        display: none;
    }

    /* One row: the mic, the field and the launcher side by side, instead of the field over a
       full-width button (two rows that cost the card 54px on a phone, and a wrapped second row on a
       tablet, where the 560px field and the labelled button did not fit side by side). */
    .home-fit > .compose-bar {
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: flex-end;
        justify-content: center;
        gap: 8px;
    }

    .home-fit .compose-slot {
        flex: 1 1 0;
        width: auto;
        max-width: 560px;
        min-width: 0;
    }

    .home-fit .compose-hand {
        flex: none;
        width: auto;
    }
}

/* ---- 5. phones: give back the height that is cheap to give --------------------------------------- */

@media (max-width: 720px) {
    .chronos-root.home-fit {
        gap: 8px;
    }

    .home-fit > .horizon-tabs {
        margin-bottom: 0;
    }

    .home-fit .card.calendar {
        padding-block: 8px;
    }

    /* The one-week row: rounded cells a little shorter than square. The week is already one row
       (02-main-layout.css), this only trims each cell's height. */
    .home-fit .cal-grid .calday {
        height: 38px;
        aspect-ratio: auto;
    }

    /* The month face (Quarter and Global): two rows of six instead of three columns by four. The
       266px picker pushed a 375x667 board past the screen and the compose bar under the fold; two
       short rows land near the one-week row's height, so the card barely moves between horizons. */
    .home-fit .cal-months {
        grid-template-columns: repeat(6, 1fr);
        gap: 4px;
        padding: 2px 0;
    }

    .home-fit .calmonth {
        padding: 8px 2px;
        font-size: var(--text-sm);
    }

    .home-fit .aggregate {
        padding-block: 6px 2px;
    }

    .home-fit .tasks-scroll.is-timeline {
        padding-top: 8px;
    }

    .home-fit .tasks-scroll.is-timeline .main-task {
        margin-block: 10px 4px;
    }

    /* One row of deadline chips, the 40px chips plus a hair. */
    .home-fit .tl-strip {
        height: 44px;
    }

    .home-fit .board-timeline {
        padding: 2px 12px 10px;
    }

    .home-fit .board-timeline > .tl {
        gap: 4px;
    }
}

/* A SHORT PHONE HAS ONE SCROLLER. At 375x667 with a deadline strip the card's region had 214px for
   278px of content, so the hour box sat on its floor half below the region: a reader scrolled the
   card, then the box inside it, and saw 26 to 74px of hours. Here the box stops scrolling and lays
   out its whole axis, and the region is the only scroller; chronosCalendar.scrollTimeline then opens
   the region at the anchor instead of the box. overflow-x: clip keeps the axis from widening the
   card without making the box a scroll container again. */
@media (max-width: 720px) and (max-height: 700px) {
    .home-fit .tl-scroll {
        flex: none;
        height: auto;
        min-height: 0;
        overflow-x: clip;
        overflow-y: visible;
    }
}

@media (max-width: 480px) {
    .chronos-root.home-fit {
        gap: 6px;
        padding-bottom: max(8px, env(safe-area-inset-bottom, 0px));
    }

    .home-fit > .main-area {
        gap: 6px;
    }

    /* The launcher folds to a round + the height of the field. Its words stay in the button for
       screen readers, and the button's title still names it. */
    .home-fit .compose-hand {
        width: 43px;
        height: 43px;
        padding: 0;
        justify-content: center;
    }

    .home-fit .compose-hand-text {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
    }

    /* The timeline's header loses its day on a narrow phone: the calendar row right above already
       marks that day (or that week), and the line it frees goes to the hour box. The totals and
       "N more in the list" share one line; the totals give way first. The box keeps the day as its
       accessible name. */
    .home-fit .tl-head {
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas: "stats more";
        min-height: 24px;
        row-gap: 0;
    }

    .home-fit .tl-head > .tl-title {
        display: none;
    }

    /* On that one line the free total reads first, the separator after it, and the planned total
       trails: it is the one that gives way (54-timeline.css, .tl-stat). The DOM order stays, so a
       screen reader still hears planned, then free. */
    .home-fit .tl-stat-free,
    .home-fit .tl-stat-off {
        order: -2;
    }

    .home-fit .tl-stat-sep {
        order: -1;
    }
}
