/* Read-only views of Jim's calendar. Same visual grammar and token names as
   the calendar itself (~/git/cal/style.css): flat, hairline, colour only
   where it means something. Midnight default; Ivory via data-theme="ivory".
   Kept as its own copy on purpose, so a change to the app's look never
   changes a public page by accident. */

:root {
  --page: #10181d; --panel: #16212a; --panel-2: #1b2831; --line: #24333d;
  --ink: #c8d6dd; --ink-dim: #7d919c; --ink-strong: #ffffff; --ink-off: #4d5c66;
  --accent: #38bdf8;
  --up: #4ade80; --up-ink: #4ade80;
  --plan: #8b9dc9; --plan-ink: #8b9dc9;
  --hover: #1d2b35; --selected: #1f3340; --shadow-color: rgba(0,0,0,.45);
  --work: #2f8a57; --personal: #e05a9c;
}
:root[data-theme="ivory"] {
  --page: #efe9dd; --panel: #faf6ee; --panel-2: #f3ede1; --line: #e2d8c6;
  --ink: #4c463f; --ink-dim: #6b6354; --ink-strong: #2f2b25; --ink-off: #bcb3a2;
  --accent: #6389ad;
  --up: #86c39c; --up-ink: #4e8f6a;
  --plan: #a9a2cd; --plan-ink: #6e66a3;
  --hover: #f2ebdd; --selected: #ece3d1; --shadow-color: rgba(122,104,74,.16);
  --work: #2f8a57; --personal: #e05a9c;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overscroll-behavior-x: none; }
body {
  padding: 16px; background: var(--page); color: var(--ink);
  font: 13px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
}
.shell {
  display: grid; grid-template-columns: minmax(0, 1fr) 320px;
  max-width: 1180px; height: 100%; margin: 0 auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
}
.month { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.side { border-left: 1px solid var(--line); min-height: 0; overflow-y: auto; padding: 12px 16px 16px; }
.foot { display: none; }
.label {
  display: block; font-size: 10px; font-weight: 600; letter-spacing: .6px;
  text-transform: uppercase; color: var(--ink-dim);
}
.who { padding: 10px 14px 0; }

.bar-top { position: relative; display: flex; align-items: center; gap: 8px; padding: 8px 12px 10px 8px; }
.bar-top .title {
  font: inherit; font-size: 16px; font-weight: 600; color: var(--ink-strong); white-space: nowrap;
  background: transparent; border: 0; border-radius: 5px; margin: 0; padding: 3px 6px; cursor: pointer;
}
.bar-top .title:hover { background: var(--hover); }

/* The month list, opened from the month name. */
.months {
  position: absolute; z-index: 10; top: calc(100% - 4px); left: 8px;
  width: 190px; max-height: 340px; overflow-y: auto; overscroll-behavior: contain; padding: 4px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 8px 24px var(--shadow-color);
}
.months[hidden] { display: none; }
.months .label { padding: 9px 10px 3px; color: var(--personal); }   /* the year */
.months button {
  display: block; width: 100%; text-align: left; font: inherit; color: var(--ink); cursor: pointer;
  background: transparent; border: 0; border-radius: 5px; padding: 5px 10px;
}
.months button:hover { background: var(--hover); }
.months button.on { background: var(--selected); color: var(--ink-strong); box-shadow: inset 0 0 0 1px var(--accent); }
.bar-top .spacer { flex: 1; }
.btn {
  font: inherit; color: var(--ink); background: transparent; white-space: nowrap;
  border: 1px solid var(--line); border-radius: 5px; padding: 4px 10px; cursor: pointer;
}
.btn:hover { background: var(--hover); }
.btn.pill { border-radius: 999px; padding-left: 12px; padding-right: 12px; }
/* Today sits at the exact centre of the bar, whatever is either side of it. */
.bar-top .pill { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); }

.note { padding: 5px 14px 6px; border-top: 1px solid var(--line); color: var(--ink-dim); font-size: 12px; }
.note[hidden] { display: none; }

/* ---------- month grid ---------- */
.heads { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.heads div {
  padding: 4px 7px; font-size: 10px; font-weight: 600; letter-spacing: .6px;
  text-transform: uppercase; color: var(--ink-dim);
}
.weeks { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow-y: auto; touch-action: pan-y; }
.week { position: relative; flex: 1 0 auto; min-height: 96px; }
.cells { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cell {
  position: relative; display: block; margin: 0; padding: 4px 5px;
  font: inherit; color: var(--ink); text-align: left; user-select: none; -webkit-user-select: none;
  background: transparent; border: 0; border-top: 1px solid var(--line); border-right: 1px solid var(--line);
}
.cell:last-child { border-right: 0; }
.cell .num {
  position: absolute; top: 3px; display: inline-block; min-width: 20px; height: 20px; line-height: 18px; padding: 0 4px;
  text-align: center; font-size: 12px; font-variant-numeric: tabular-nums;
  border: 1px solid transparent; border-radius: 999px;
}
.cell.out .num { color: var(--ink-off); }
.cell.today .num { border-color: var(--accent); color: var(--ink-strong); font-weight: 600; }

/* full view: days can be picked, entries are bars */
.full .cell { cursor: pointer; }
.full .cell:hover { background: var(--hover); }
.full .cell.sel { background: var(--selected); box-shadow: inset 0 0 0 1px var(--accent); }
.bars {
  position: relative; pointer-events: none;
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
  grid-auto-rows: 19px; grid-auto-flow: row dense; row-gap: 3px;
  padding: 28px 0 8px;
}
.bar {
  margin: 0 4px; padding: 0 6px; min-width: 0;
  display: flex; align-items: center;
  font-size: 11.5px; line-height: 1; white-space: nowrap; overflow: hidden;
  border: 1px solid transparent; border-radius: 4px;
}
.bar span { overflow: hidden; }
.bar.job.confirmed {
  color: var(--ink-strong);
  background: color-mix(in srgb, var(--work) 24%, var(--panel));
  border-color: color-mix(in srgb, var(--work) 62%, var(--panel));
}
.bar.job.pencilled { color: var(--ink); border: 1px dashed var(--work); }
.bar.personal {
  color: var(--ink-strong);
  background: color-mix(in srgb, var(--personal) 16%, var(--panel));
  border-color: color-mix(in srgb, var(--personal) 48%, var(--panel));
}
.bar.personal.pencilled { color: var(--ink); background: transparent; border: 1px dashed var(--personal); }
.bar.note { color: var(--ink); border-color: var(--ink-off); }   /* information: no colour */
.bar.contL { margin-left: 0; border-left: 0; border-top-left-radius: 0; border-bottom-left-radius: 0; }
.bar.contR { margin-right: 0; border-right: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; }

/* availability view: the day itself carries the state */
.availability .week { min-height: 72px; }
.cell.free { background: color-mix(in srgb, var(--up) 14%, var(--panel)); }
.cell.maybe { background: color-mix(in srgb, var(--plan) 9%, var(--panel)); outline: 1px dashed var(--plan-ink); outline-offset: -4px; }
.cell.booked .num, .cell.past .num { color: var(--ink-off); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 0 14px 10px; color: var(--ink-dim); font-size: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--line); }
.legend i.free { background: color-mix(in srgb, var(--up) 14%, var(--panel)); }
.legend i.maybe { background: color-mix(in srgb, var(--plan) 9%, var(--panel)); border: 1px dashed var(--plan-ink); }

/* ---------- side panel ---------- */
.side h2 { margin: 0; font-size: 15px; font-weight: 600; color: var(--ink-strong); }
.side h2 + .label { min-height: 15px; margin-bottom: 10px; }
.entry { border-top: 1px solid var(--line); margin: 0 -16px; padding: 11px 16px 12px; }
.entry .row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.entry .name { margin: 3px 0 6px; font-size: 14px; font-weight: 600; color: var(--ink-strong); overflow-wrap: anywhere; }
.entry .when { color: var(--ink); font-variant-numeric: tabular-nums; }
.days { display: grid; grid-template-columns: 84px 1fr; row-gap: 2px; color: var(--ink-dim); font-variant-numeric: tabular-nums; }
.days .on { color: var(--ink-strong); }
.chip { font-size: 11px; padding: 1px 9px; border-radius: 999px; border: 1px solid; white-space: nowrap; }
.chip.confirmed { border-color: var(--up); color: var(--up-ink); }
.chip.pencilled { border: 1px dashed var(--plan-ink); color: var(--plan-ink); }
.empty { border-top: 1px solid var(--line); padding: 12px 0; color: var(--ink-dim); }
.block { border-top: 1px solid var(--line); margin: 0 -16px; padding: 11px 16px 12px; }
.block .label { margin-bottom: 6px; }
.block div { color: var(--ink); font-variant-numeric: tabular-nums; padding: 1px 0; }
.block .none { color: var(--ink-dim); }

/* ---------- phone ---------- */
@media (max-width: 700px) {
  html, body { height: auto; }
  body { padding: 0 0 env(safe-area-inset-bottom); background: var(--panel); }
  .shell { display: block; height: auto; border: 0; border-radius: 0; overflow: visible; }
  .side { border-left: 0; border-top: 1px solid var(--line); overflow: visible; padding: 14px 16px 20px; font-size: 16px; }
  .foot { display: block; padding: 4px 16px 24px; }
  .bar-top { padding: 6px 8px 8px 6px; gap: 6px; min-height: 58px; }   /* room for the centred Today */
  .btn.pill { padding: 0 16px; }
  .months { width: 230px; max-height: 60vh; }
  .months button { min-height: 44px; font-size: 16px; padding: 5px 12px; }
  .bar-top .theme-btn { display: none; }
  .btn { min-height: 44px; min-width: 44px; padding: 0 12px; font-size: 15px; }
  .heads div { padding: 4px 0; text-align: center; font-size: 9.5px; }
  .weeks { display: block; overflow: visible; }
  .week { min-height: 76px; }
  .availability .week { min-height: 56px; }
  .cell { padding: 2px; }
  .cell .num { top: 2px; left: 50%; transform: translateX(-50%); }
  .availability .cell .num { top: 50%; transform: translate(-50%, -50%); }
  .bars { grid-auto-rows: 15px; row-gap: 2px; padding: 25px 0 5px; }
  .bar { margin: 0 1px; padding: 0 3px; font-size: 10px; border-radius: 3px; }
  .legend { font-size: 13px; padding: 0 12px 10px; }
  .note { font-size: 13px; }
  .side h2 { font-size: 18px; }
  .label { font-size: 10.5px; }
  .entry .name { font-size: 17px; }
  .days { grid-template-columns: 104px 1fr; row-gap: 4px; }
  .chip { font-size: 13px; padding: 2px 11px; }
}
