/* ============================================================
   Timeshare — editorial / risograph scheduling calendar
   ============================================================ */

:root {
  --paper:      #f1ebdd;
  --paper-2:    #e9e1cf;
  --card:       #fbf7ee;
  --ink:        #211e18;
  --ink-soft:   #6c6453;
  --line:       #d8cdb4;
  --line-strong:#b6a787;   /* day-cell borders — clearly delimits each day */

  --a:          #156b63;   /* person A — deep teal */
  --a-soft:     #d3e4df;
  --a-ink:      #0c443f;
  --k:          #cf5634;   /* person K — terracotta */
  --k-soft:     #f3ddcf;
  --k-ink:      #8a3015;

  --today:      #caa43a;   /* brass */

  --radius:     14px;
  --radius-sm:  9px;
  --shadow:     0 1px 0 rgba(33,30,24,.04), 0 12px 28px -18px rgba(33,30,24,.45);

  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans:  "Hanken Grotesk", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

/* ---------- Login gate ----------
   Until authenticated the app chrome is hidden and only the password box
   shows, centered. `is-authed` (added by app.js) flips to the full app. */
.masthead, .months, .footer { display: none; }
body.is-authed .masthead { display: block; }
body.is-authed .months   { display: grid; }
body.is-authed .footer   { display: flex; }
body.is-authed .login    { display: none; }

.login {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login__input {
  font-family: var(--serif);
  font-size: 1.35rem;
  text-align: center;
  width: min(360px, 82vw);
  padding: 15px 22px;
  color: var(--ink);
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: 999px;
  box-shadow: var(--shadow);
  outline: none;
}
.login__input::placeholder { color: var(--ink-soft); font-style: italic; }
.login__input:focus {
  border-color: var(--today);
  box-shadow: 0 0 0 4px rgba(202,164,58,.25), var(--shadow);
}
.login.is-error .login__input {
  border-color: var(--k);
  animation: shake .3s ease;
}
@keyframes shake {
  25% { transform: translateX(-7px); }
  75% { transform: translateX(7px); }
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(120% 80% at 100% 0%, var(--paper-2) 0%, transparent 55%),
    radial-gradient(110% 70% at 0% 100%, #efe7d4 0%, transparent 50%),
    var(--paper);
  background-attachment: fixed;
  padding: clamp(14px, 3vw, 36px);
  padding-bottom: 96px;
}

/* film grain overlay */
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9;
  opacity: .5;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.4'/%3E%3C/svg%3E");
}

/* ---------- Masthead ---------- */
.masthead {
  max-width: 680px;
  margin: 0 auto clamp(18px, 3vw, 30px);
}
.masthead__inner {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  border-bottom: 2px solid var(--ink);
  padding-bottom: 12px;
}
.kicker {
  display: block;
  font-size: .72rem;
  letter-spacing: .26em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-weight: 700;
  margin-bottom: 2px;
}
.masthead h1 {
  font-family: var(--serif);
  font-optical-sizing: auto;
  font-weight: 600;
  font-size: clamp(2.4rem, 9vw, 4.2rem);
  line-height: .9;
  margin: 0;
  letter-spacing: -.02em;
  font-style: italic;
}
.masthead__hint {
  margin: 12px 2px 0;
  color: var(--ink-soft);
  font-size: .92rem;
  max-width: 60ch;
}
.masthead__hint em {
  font-style: normal;
  font-weight: 700;
  color: var(--ink);
}

/* legend chips */
.legend { display: flex; gap: 8px; padding-bottom: 4px; }
.legend__chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--sans);
  font-weight: 700;
  font-size: .95rem;
  color: var(--ink);
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: 7px 14px 7px 9px;
  cursor: pointer;
  transition: border-color .15s, transform .1s, box-shadow .15s;
}
.legend__chip:hover { border-color: var(--ink-soft); box-shadow: var(--shadow); }
.legend__chip:active { transform: scale(.96); }
.legend__chip[aria-expanded="true"] { border-color: var(--ink); }
.legend__chip::after {
  content: "▾";
  font-size: .65rem;
  color: var(--ink-soft);
  margin-left: 1px;
}
.dot { width: 13px; height: 13px; border-radius: 50%; display: inline-block; }
.dot--a { background: var(--a); }
.dot--k { background: var(--k); }

/* ---------- Months layout ---------- */
/* One month per row, in a focused column — keeps the day cells (and so the
   three bands) wide enough to read and tap comfortably. */
.months {
  max-width: 680px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr;
  gap: clamp(18px, 3vw, 30px);
}

.month {
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(12px, 2.4vw, 20px);
}
.month__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}
.month__name {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(1.3rem, 4.5vw, 1.7rem);
  letter-spacing: -.01em;
  margin: 0;
}
.month__year {
  font-family: var(--sans);
  font-weight: 700;
  letter-spacing: .14em;
  color: var(--ink-soft);
  font-size: .8rem;
}

.weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  column-gap: 5px;
  margin-bottom: 6px;
}
.weekdays span {
  text-align: center;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  padding: 2px 0;
}
.weekdays span:first-child { color: var(--k-ink); }  /* Monday stands out */

/* A small gap + a solid border per day makes each day a distinct card, so it's
   obvious which three strips belong to which day. */
.grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
}

/* ---------- Day cell ---------- */
/* The date lives in its own header row, so it never overlaps band content. */
.day {
  position: relative;
  display: flex;
  flex-direction: column;
  aspect-ratio: 1 / 1.12;           /* shorter again — the bands no longer dodge the date */
  overflow: hidden;                 /* clips strip fills to the rounded border */
  background: var(--card);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm);
  font-family: var(--sans);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;      /* no iOS callout on long-press */
  user-select: none;
}
.day.is-blank {
  visibility: hidden;
  pointer-events: none;
}

/* past days slightly recede */
.day.is-past { opacity: .62; }
.day.is-past.is-today { opacity: 1; }

/* fixed-height header so every day's date strip is the same height (the brass
   today pill must not make its row taller) */
.day__num {
  flex: 0 0 auto;
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  height: 16px;
  margin: 2px 0 1px 3px;
  padding: 0 4px;
  font-size: .7rem;
  font-weight: 700;
  line-height: 1;
  color: var(--ink-soft);
}

/* today — prominent brass border + glow, plus a brass day number */
.day.is-today {
  border-color: var(--today);
  border-width: 2.5px;
  box-shadow: 0 0 0 3px rgba(202, 164, 58, .4);
  z-index: 2;
}
.day.is-today .day__num {
  color: var(--ink);
  background: var(--today);
  font-weight: 800;
  border-radius: 999px;
}

/* ---------- Strips (morning · afternoon · evening) ---------- */
.strips {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--line);
}
.strip {
  position: relative;
  border: 0;
  margin: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--serif);
  color: #fff;
  transition: filter .12s ease;
}
.strip:focus-visible { outline: 3px solid var(--today); outline-offset: -3px; z-index: 5; }

/* faint rules between empty bands hint the three-part split within a day */
.strip.is-empty:not(:first-child) { box-shadow: inset 1px 0 0 var(--line); }
.strip.is-empty:hover { background: rgba(33, 30, 24, .04); }

/* filled plain-owner strips: solid colour; same-owner neighbours sit flush, so
   a run reads as one block while a handoff shows as a colour seam. The day's
   rounded border (overflow:hidden) shapes the block's outer corners. */
.strip.is-A { background: var(--a); }
.strip.is-K { background: var(--k); }
.strip.is-filled:hover { filter: brightness(1.05); }

.strip__lab {
  font-weight: 600;
  font-size: clamp(.85rem, 3.8vw, 1.25rem);
  line-height: 1;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .18);
}

/* split strip (Mon evening / Tue morning · afternoon): a two-tone band filling
   the full width, with the slot label on each half */
.strip__split {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: 1fr 1fr;
}
.strip__split b {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: clamp(.62rem, 2.7vw, .9rem);
  letter-spacing: -.02em;
}
.strip__split .seg-a { background: var(--a); box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .18); }
.strip__split .seg-k { background: var(--k); }

/* ---------- Footer / status / toast ---------- */
.footer {
  max-width: 680px;
  margin: 26px auto 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--ink-soft);
  font-size: .82rem;
}
.status { min-height: 1em; transition: opacity .3s; }

/* ---------- Color picker popover ---------- */
.popover {
  position: absolute;
  z-index: 30;
  background: var(--card);
  border: 1.5px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: 0 18px 40px -16px rgba(33,30,24,.55);
  padding: 14px;
  width: max-content;
  max-width: 240px;
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity .16s ease, transform .16s ease;
}
.popover.show { opacity: 1; transform: translateY(0); pointer-events: auto; }
.popover__title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1rem;
  margin: 0 0 10px;
}
.popover__title b { font-style: italic; }
.swatches {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 9px;
}
.swatch {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  position: relative;
  transition: transform .1s;
}
.swatch:hover { transform: scale(1.1); }
.swatch.is-active {
  border-color: var(--ink);
  box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--ink);
}
.swatch.is-active::after {
  content: "✓";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 1rem;
  font-weight: 800;
  text-shadow: 0 1px 2px rgba(0,0,0,.35);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%) translateY(8px);
  background: var(--ink);
  color: var(--paper);
  padding: 11px 18px;
  border-radius: 999px;
  font-size: .9rem;
  font-weight: 600;
  box-shadow: 0 14px 30px -12px rgba(0,0,0,.5);
  z-index: 20;
  opacity: 0;
  transition: opacity .25s, transform .25s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
