/* ==========================================================================
   Week view — planning, not glancing.

   Seven equal columns on a landscape tablet; on a phone the same seven
   columns scroll sideways with snap points, because squashing a week into a
   360px width makes every day unreadable.
   ========================================================================== */

.week {
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr;
  padding-top: var(--safe-t);
  padding-bottom: var(--safe-b);
  overflow: hidden;
}

/* --- Toolbar -------------------------------------------------------------- */
.week-bar {
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap;
  padding: 12px calc(16px + var(--safe-r)) 12px calc(16px + var(--safe-l));
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.week-title {
  display: grid; gap: 1px;
  margin-right: auto;
  min-width: 0;
}
.week-title h2 {
  font-size: clamp(19px, 1.8vw, 26px);
  font-weight: 400; font-variant: small-caps; letter-spacing: .04em;
}
.week-title span {
  font-family: var(--sans);
  font-size: 10.5px; font-weight: 600; letter-spacing: .18em;
  text-transform: uppercase; color: var(--ink-3);
}
.week-nav { display: flex; gap: 6px; }
.week-nav .btn-icon svg { width: 20px; height: 20px; }

/* One height for everything on this bar. Buttons of three different heights
   sitting in a row read as three different kinds of thing, which they are
   not — they are all "take me somewhere". */
.week-bar .btn { min-height: var(--tap); }
.week-bar .btn svg { width: 20px; height: 20px; }

/* --- The grid ------------------------------------------------------------- */
.week-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
  overflow: hidden;
  min-height: 0;
}

.day {
  display: grid;
  grid-template-rows: auto 1fr;
  background: var(--bg);
  min-height: 0;
  min-width: 0;
}
/* Today, marked three ways: a rule down its edge, a heavier head, and the word
   itself. One of those on its own was too quiet to find at a glance — which it
   has to be, because the planner rotates and today is no longer at either end.
   `box-shadow` rather than a border so the column keeps its width and the grid
   does not shift by three pixels when the day rolls over. */
.day.is-today {
  background: var(--panel-2);
  box-shadow: inset 3px 0 0 var(--ink);
}
.day.is-past  { opacity: .62; }

.day-head {
  display: flex; align-items: baseline; gap: 7px;
  padding: 11px 12px 9px;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 2;
  background: inherit;
}
.day-name {
  font-family: var(--sans);
  font-size: 10px; font-weight: 600; letter-spacing: .2em;
  text-transform: uppercase; color: var(--ink-3);
}
.day-num {
  font-variant-numeric: tabular-nums;
  font-size: 21px; font-weight: 700; letter-spacing: -.01em;
}
.day.is-today .day-head {
  border-bottom: 2px solid var(--ink);
  padding-top: 10px;
}
.day.is-today .day-num { color: var(--ink); font-weight: 800; }

/* Reversed out, the way a standfirst is. It is the only reversed type on the
   screen, so it reads as "here" without needing colour to carry it. */
.day-name.is-now {
  background: var(--ink);
  color: var(--bg);
  padding: 3px 7px 2px;
  letter-spacing: .16em;
}
.day-add {
  margin-left: auto;
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border: 1px solid var(--line-2); border-radius: var(--r);
  background: transparent; color: var(--ink-3);
  cursor: pointer; font-size: 19px; line-height: 1;
  transition: color .14s var(--ease), border-color .14s var(--ease);
}
.day-add:hover { color: var(--ink); border-color: var(--ink-3); }

.day-list {
  /* Flex, not grid: a grid row here sized itself before the title had wrapped
     and then clamped the pill, so a two-line name drew over the row below it.
     A column of flex items always sizes to what is actually in them. */
  display: flex; flex-direction: column; gap: 6px;
  align-items: stretch;
  padding: 9px 9px 24px;
  overflow-y: auto;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--line-2) transparent;
}
.day-list::-webkit-scrollbar { width: 5px; }
.day-list::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 3px; }

.day-empty {
  padding: 14px 6px;
  text-align: center;
  color: var(--ink-3);
  font-size: 13.5px; font-style: italic;
}

/* --- A pill in the week grid ---------------------------------------------- */
.pill {
  display: grid; gap: 3px;
  flex: none;
  width: 100%;
  padding: 9px 10px;
  min-height: 48px;
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--dot, var(--line-2));
  border-radius: var(--r);
  cursor: pointer;
  transition: background .14s var(--ease), transform .1s var(--ease);
}
.pill:hover  { background: var(--panel-2); }
.pill:active { transform: scale(.98); }

/* The time is an inline prefix, not a flex sibling: as a sibling it holds the
   first line hostage and a two-word title wraps into a narrow ragged column
   beside it. Inline, the title simply flows under the time. */
.pill-top { display: block; }
.pill-time {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: 12px; font-weight: 650; color: var(--ink-2);
  margin-right: 6px;
}
.pill-title {
  font-size: 14px; font-weight: 600; line-height: 1.3;
  overflow-wrap: anywhere;
}
/* `min-width: 0` on the row and on its children is what makes `.truncate`
   work in here at all. A flex item's minimum width is its content by default,
   so a long location refused to shrink and ran out past the edge of the column
   instead of ending in an ellipsis — the same trap as a grid child that will
   not collapse, one layout mode over. */
.pill-bottom {
  display: flex; align-items: center; gap: 6px;
  min-width: 0; overflow: hidden;
  font-size: 11.5px; color: var(--ink-3); font-weight: 600;
}
.pill-bottom > * { min-width: 0; }
.pill-pts {
  margin-left: auto;
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-weight: 700; color: var(--ink-2);
}
.pill.is-done { opacity: .55; }
.pill.is-done .pill-title { text-decoration: line-through; }
.pill.is-done .pill-pts { color: var(--good); }
.pill.is-late { border-left-color: var(--warn); }
.pill-repeat { color: var(--ink-3); }
.pill-repeat svg { width: 11px; height: 11px; vertical-align: -1px; }

/* Type is carried by a tiny left rail rather than a badge — a badge on every
   pill is seven columns of visual noise. */
.pill[data-type="event"] { border-left-style: solid; }
.pill[data-type="chore"] { border-left-style: solid; }
.pill[data-type="task"]  { border-left-style: dashed; }

/* --- Phone: horizontal scroll with snap ----------------------------------- */
@media (max-width: 900px) {
  .week-grid {
    grid-auto-flow: column;
    grid-auto-columns: 78vw;
    grid-template-columns: none;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
  }
  .day { scroll-snap-align: start; }
  .day-list { padding-bottom: 40px; }
  .week-title { width: 100%; margin-bottom: 4px; }
}

@media (max-width: 600px) {
  .week-grid { grid-auto-columns: 88vw; }
  .week-bar { padding-left: calc(12px + var(--safe-l)); padding-right: calc(12px + var(--safe-r)); }
}

/* ==========================================================================
   The planner on a phone
   --------------------------------------------------------------------------
   One day fills the screen and the week is a swipe. A peeked neighbouring
   column reads as a layout that has come apart, not as an affordance — half a
   pill hanging off the left edge looks broken because it looks broken.
   ========================================================================== */
@media (max-width: 480px) {
  .week-bar {
    gap: 6px;
    padding: 10px calc(12px + var(--safe-r)) 10px calc(12px + var(--safe-l));
  }
  .week-title { flex-basis: 100%; margin-right: 0; }
  .week-title h2 { font-size: 19px; }
  .week-nav { gap: 4px; }

  /* Six buttons at 56px do not fit 390px, so they stop being wall-sized. */
  .week-bar .btn { min-height: 46px; padding: 0 12px; font-size: 15px; }
  .week-bar .btn-icon { min-width: 46px; padding: 0 10px; }
  .week-bar .btn svg { width: 18px; height: 18px; }

  .week-grid { grid-auto-columns: 100%; }
  .day-head { padding: 10px 10px 6px; }
  .day-list { padding: 8px 8px 28px; }
  .pill { padding: 8px 10px; }
  .pill-title { font-size: 15px; }
}
