/* jacobwillard.pages.dev: the iPhone calendar look (option 1, 2026-10-21).
   System type, hairline grid, quiet striped busy time, sunset now line, booking in a bottom sheet
   (phone) or a popover beside the picked block (desktop, 760 px and up). */

:root {
  --bg: #FFFFFF; --fill: #F2F2F5; --fill-2: #E6E6EB; --group: #F2F2F7;
  --sep: #E6E6EA; --ink: #111214; --ink-2: #3C3C43; --label: #8A8A8F; --faint: #C4C4C9;
  --navy: #1d2e4e; --navy-2: #26395e; --sun: #e97451; --sun-ink: #d65f3c;
  --gut: 58px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --hatch: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='7' height='7'%3E%3Cpath d='M-1 1l2-2M0 7L7 0M6 8l2-2' stroke='%23DADAE0' stroke-width='1'/%3E%3C/svg%3E");
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; }
body {
  font: 15px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", system-ui, sans-serif;
  color: var(--ink); background: var(--bg); letter-spacing: -0.008em;
  -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, p { margin: 0; font: inherit; }
button { font: inherit; color: inherit; border: 0; padding: 0; background: none; cursor: pointer; -webkit-user-select: none; user-select: none; }
button:disabled { cursor: default; }
input, textarea { font: inherit; color: var(--ink); }
:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; }
svg { display: block; }

.app { padding-bottom: max(calc(84px + var(--safe-b)), var(--sheet-h, 0px)); }

/* ---------- who ---------- */
.top {
  display: flex; align-items: center; gap: 10px;
  padding: 14px max(16px, var(--safe-r)) 8px max(16px, var(--safe-l));
}
.av {
  width: 34px; height: 34px; border-radius: 50%; background: var(--navy); color: #fff;
  display: grid; place-items: center; font-size: 15px; font-weight: 600; letter-spacing: 0; flex: none;
}
.who { min-width: 0; }
.who h1 { display: block; font-size: 16px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; }
.who span { display: block; font-size: 13px; color: var(--label); line-height: 1.25; }
.seg { margin-left: auto; display: flex; background: var(--fill); border-radius: 8px; height: 32px; padding: 2px; flex: none; }
.seg button {
  position: relative; height: 28px; min-width: 32px; padding: 0 10px; border-radius: 6px;
  font-size: 14px; font-weight: 500; display: grid; place-items: center;
}
.seg button::after { content: ""; position: absolute; inset: -8px -2px; } /* 44 px tap target */
.seg button:active:not(:disabled) { background: var(--fill-2); }
.seg button:disabled { color: var(--faint); }
.seg .arrow { display: none; }
.seg .today { padding: 0 12px; }
.seg svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- desktop month row (hidden on phone) ---------- */
.mrow, .heads { display: none; }

/* ---------- week strip (phone) ---------- */
.sticky { position: sticky; top: 0; z-index: 10; background: var(--bg); }
.week {
  display: grid; grid-template-columns: repeat(7, 1fr); min-height: 58px;
  padding: 4px max(6px, var(--safe-r)) 0 max(6px, var(--safe-l));
  touch-action: pan-y;
}
.wk { display: flex; flex-direction: column; align-items: center; gap: 3px; min-height: 54px; }
.wk i { font-style: normal; font-size: 11px; font-weight: 500; color: var(--label); letter-spacing: 0.02em; }
.wk b {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  font-size: 19px; font-weight: 400; letter-spacing: -0.02em; transition: background-color .15s var(--ease);
}
.wk.out b { color: var(--faint); }
.wk.today b { color: var(--sun-ink); font-weight: 600; }
.wk:active:not(:disabled) b { background: var(--fill); }
.wk.on b, .wk.on:active b { background: var(--ink); color: #fff; font-weight: 600; }
.wk:focus-visible { outline: 0; }
.wk:focus-visible b { outline: 2px solid var(--navy); outline-offset: 2px; }
.dline { text-align: center; font-size: 15px; padding: 9px 0 10px; border-bottom: 1px solid var(--sep); color: var(--ink); min-height: 40px; }
.dline b { font-weight: 600; margin-right: 6px; }

/* ---------- grid ---------- */
.gridwrap { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.grid { position: relative; }
.lines { position: absolute; inset: 0; pointer-events: none; }
.hl { position: absolute; left: var(--gut); right: 0; height: 0; border-top: 1px solid var(--sep); }
.hlab {
  position: absolute; left: 0; width: calc(var(--gut) - 10px); text-align: right; font-size: 11px; color: var(--label);
  transform: translateY(-50%); white-space: nowrap; font-weight: 500; letter-spacing: 0;
}
.hlab.tag { font-weight: 600; }
.hlab.k-sel { color: var(--navy); }
.hlab.k-now { color: var(--sun-ink); }
.cols { position: absolute; left: var(--gut); right: max(6px, var(--safe-r)); top: 8px; bottom: 8px; display: grid; touch-action: pan-y; }
.col { position: relative; }
.free { position: absolute; left: 0; right: 0; z-index: 1; cursor: pointer; }
.free:focus-visible { outline: 2px solid var(--navy); outline-offset: -2px; border-radius: 6px; }
.pastz { position: absolute; left: 0; right: 0; top: 0; background: #FAFAFB; }
.busy { position: absolute; left: 3px; right: 4px; z-index: 2; border-radius: 6px; background: #FBFBFC var(--hatch); border: 1px solid #ECECF0; }
.now { position: absolute; left: -4px; right: 0; height: 0; border-top: 1.5px solid var(--sun); z-index: 6; pointer-events: none; }
.now::before { content: ""; position: absolute; left: 0; top: -5px; width: 9px; height: 9px; border-radius: 50%; background: var(--sun); }
.sel {
  position: absolute; left: 3px; right: 4px; z-index: 7; border-radius: 6px; background: var(--navy); color: #fff;
  padding: 4px 8px; box-shadow: 0 6px 16px rgba(17, 18, 20, 0.16); cursor: grab; touch-action: none;
}
.sel:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.sel-t { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; line-height: 1.3; }
.sel b { font-size: 13px; font-weight: 600; letter-spacing: -0.01em; }
.sel span { font-size: 13px; color: rgba(255, 255, 255, .72); margin-left: 6px; }
.sel.short { padding-top: 0; padding-bottom: 0; display: flex; align-items: center; }
.sel.tiny b, .sel.tiny span { font-size: 11px; }
.sel.tiny .sel-t { line-height: 1; }
.hd { position: absolute; width: 11px; height: 11px; border-radius: 50%; background: #fff; border: 2px solid var(--navy); cursor: ns-resize; touch-action: none; z-index: 1; }
.hd::before { content: ""; position: absolute; inset: -17px; } /* 45 px grab area */
.hd.t { top: -6px; right: 14px; }
.hd.b { bottom: -6px; left: 14px; }
body.dragging, body.dragging * { cursor: grabbing !important; }
body.resizing, body.resizing * { cursor: ns-resize !important; }

/* Loading: the same grid with quiet blocks where busy time will land. */
.sk { position: absolute; left: 3px; right: 4px; border-radius: 6px; background: var(--fill); animation: pulse 1.2s var(--ease) infinite alternate; }
@keyframes pulse { from { opacity: 1; } to { opacity: .45; } }

/* ---------- hint pill (phone) ---------- */
.coach {
  position: fixed; left: 50%; bottom: calc(28px + var(--safe-b)); z-index: 20;
  transform: translateX(-50%); background: var(--ink); color: #fff; font-size: 14px; font-weight: 500;
  padding: 11px 16px; border-radius: 10px; white-space: nowrap; display: flex; gap: 8px; align-items: center;
  box-shadow: 0 8px 24px rgba(17, 18, 20, .18); pointer-events: none;
  transition: opacity .2s var(--ease), transform .2s var(--ease);
}
.coach.gone { opacity: 0; transform: translate(-50%, 8px); }
.coach svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; opacity: .8; }

/* ---------- booking sheet (phone) ---------- */
.sheet {
  position: fixed; left: 0; right: 0; bottom: var(--kb, 0px); z-index: 30;
  max-height: calc(var(--vvh, 100dvh) - 12px); overflow-y: auto; overscroll-behavior: contain;
  background: var(--group); border-radius: 14px 14px 0 0;
  padding: 6px max(16px, var(--safe-r)) max(26px, calc(12px + var(--safe-b))) max(16px, var(--safe-l));
  box-shadow: 0 -1px 0 rgba(0, 0, 0, .04), 0 -10px 30px rgba(17, 18, 20, .10);
  transform: translateY(calc(100% + 24px)); visibility: hidden;
  transition: transform .2s var(--ease), visibility 0s linear .2s;
}
.sheet.open { transform: none; visibility: visible; transition: transform .2s var(--ease), visibility 0s; }
.sheet.kb { padding-bottom: 12px; }
.grab { width: 36px; height: 5px; border-radius: 3px; background: #C9C9CE; margin: 0 auto 12px; }
.sh-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 0 2px 14px; }
.sh-time { font-size: 22px; font-weight: 600; letter-spacing: -0.025em; line-height: 1.15; }
.sh-sub { font-size: 15px; color: var(--label); margin-top: 3px; }
.x {
  position: relative; width: 30px; height: 30px; border-radius: 50%; background: var(--fill-2); color: #6C6C72;
  display: grid; place-items: center; flex: none;
}
.x::after { content: ""; position: absolute; inset: -7px; }
.x:active { background: #D9D9DF; }
.x svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
.group { background: #fff; border-radius: 12px; margin-bottom: 14px; overflow: hidden; }
.cell { display: block; padding: 0 16px; position: relative; cursor: text; }
.cell + .cell::before { content: ""; position: absolute; left: 16px; right: 0; top: 0; border-top: 1px solid var(--sep); }
.cell input, .cell textarea {
  display: block; width: 100%; border: 0; outline: 0; background: transparent; font-size: 17px; height: 46px; padding: 0;
  letter-spacing: -0.015em; caret-color: var(--navy); border-radius: 0; -webkit-appearance: none; appearance: none;
}
.cell textarea { height: 46px; padding: 12px 0; resize: none; line-height: 22px; }
.cell ::placeholder { color: #A3A3A8; opacity: 1; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.err { display: flex; gap: 6px; align-items: flex-start; color: var(--sun-ink); font-size: 15px; font-weight: 500; line-height: 1.35; padding: 0 2px 12px; }
.err svg { width: 18px; height: 18px; flex: none; margin-top: 1px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.book {
  width: 100%; height: 50px; border-radius: 12px; background: var(--navy); color: #fff;
  font-size: 17px; font-weight: 600; letter-spacing: -0.015em; transition: transform .1s var(--ease), background-color .1s;
}
.book:hover { background: var(--navy-2); }
.book:active:not(:disabled) { background: var(--navy-2); transform: scale(.985); }
.book:disabled { background: var(--fill-2); color: var(--label); cursor: default; }
.book.busy-state:disabled { background: var(--navy); color: rgba(255, 255, 255, .8); cursor: progress; }

/* ---------- states ---------- */
.state { padding: 48px 24px; text-align: center; }
.state .msg { color: var(--ink-2); font-size: 15px; margin-bottom: 16px; }
.btn {
  height: 44px; padding: 0 20px; border-radius: 10px; background: var(--navy); color: #fff;
  font-size: 15px; font-weight: 600; transition: transform .1s var(--ease);
}
.btn:active { background: var(--navy-2); transform: scale(.985); }

.done { padding: 28px max(20px, var(--safe-r)) 40px max(20px, var(--safe-l)); }
.done svg { width: 32px; height: 32px; fill: none; stroke: var(--navy); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; margin-bottom: 14px; }
.done h2 { font-size: 28px; font-weight: 700; letter-spacing: -0.03em; margin-bottom: 14px; }
.done .day { font-size: 17px; font-weight: 600; letter-spacing: -0.015em; }
.done .time { font-size: 17px; color: var(--ink-2); margin-top: 2px; }
.done .next { font-size: 15px; color: var(--label); margin-top: 14px; }
.is-done .mrow, .is-done .sticky, .is-done .heads, .is-done .gridwrap, .is-done .state, .is-done .seg { display: none; }
.is-done .app { padding-bottom: 0; }

/* ---------- desktop: week view, booking popover ---------- */
@media (min-width: 760px) {
  .app { max-width: 1440px; margin: 0 auto; padding-bottom: 24px; }
  .top { padding: 18px 28px 0; }
  .seg .arrow { display: grid; }
  .seg .today { padding: 0 10px; }
  .seg .today.on { background: #fff; box-shadow: 0 0 0 0.5px rgba(0, 0, 0, .06), 0 1px 2px rgba(0, 0, 0, .08); }
  .seg button:hover:not(:disabled):not(.on) { background: var(--fill-2); }
  .sticky { display: none; }
  .mrow { display: flex; align-items: baseline; justify-content: space-between; gap: 24px; padding: 18px 28px 12px; }
  .month { font-size: 28px; font-weight: 700; letter-spacing: -0.03em; white-space: nowrap; }
  .month span { font-weight: 400; color: var(--label); }
  .hint { font-size: 13px; color: var(--label); text-align: right; }
  .heads { display: grid; margin: 0 34px 0 calc(var(--gut) + 14px); border-bottom: 1px solid var(--sep); padding-bottom: 8px; }
  .chead { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 13px; color: var(--ink-2); }
  .chead b {
    width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
    font-size: 15px; font-weight: 500; color: var(--ink);
  }
  .chead.today { color: var(--sun-ink); font-weight: 600; }
  .chead.today b { background: var(--sun); color: #fff; font-weight: 600; }
  .gridwrap { padding: 0 28px 0 14px; }
  .cols { right: 6px; }
  .col { border-left: 1px solid var(--sep); }
  .busy { border-radius: 5px; }
  .sel { padding: 3px 7px; }
  .sel-t { line-height: 13px; }
  .sel b, .sel span { font-size: 11.5px; display: block; margin: 0; }
  .sel.short b, .sel.short span { display: inline; }
  .sel.short span { margin-left: 5px; }
  .sel.tiny b, .sel.tiny span { font-size: 10.5px; }
  .hd.t { right: 10px; }
  .hd.b { left: 10px; }
  .coach { display: none; }
  .state { padding: 80px 24px; }

  .sheet {
    position: absolute; right: auto; bottom: auto; left: 0; top: 0; width: 332px; max-height: none; overflow: visible;
    background: #F7F7F8; border-radius: 12px; padding: 16px;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, .07), 0 12px 32px rgba(17, 18, 20, .16);
    transform: scale(.98); opacity: 0;
    transition: opacity .16s var(--ease), transform .16s var(--ease), visibility 0s linear .16s;
  }
  .sheet.open { transform: none; opacity: 1; transition: opacity .16s var(--ease), transform .16s var(--ease), visibility 0s; }
  .sheet.open.away, .creating .sheet.open { visibility: hidden; opacity: 0; transition: none; }
  .sheet::before {
    content: ""; position: absolute; left: -7px; top: var(--ay, 40px); width: 14px; height: 14px; background: #F7F7F8;
    transform: rotate(45deg); box-shadow: -1px 1px 0 rgba(0, 0, 0, .07);
  }
  .sheet.flip::before { left: auto; right: -7px; box-shadow: 1px -1px 0 rgba(0, 0, 0, .07); }
  .grab { display: none; }
  .sh-head { padding: 0 0 14px; }
  .sh-time { font-size: 19px; }
  .sh-sub { font-size: 13px; }
  .group { margin-bottom: 10px; box-shadow: 0 0 0 1px var(--sep); }
  .cell input { height: 38px; font-size: 14px; }
  .cell textarea { height: 54px; font-size: 14px; padding: 10px 0; line-height: 18px; }
  .err { font-size: 13px; padding-bottom: 10px; }
  .err svg { width: 16px; height: 16px; }
  .book { height: 38px; font-size: 14px; border-radius: 8px; margin-top: 4px; }
  .x { width: 26px; height: 26px; }
  .x:hover { background: #DCDCE1; }
  .done { padding: 40px 28px; max-width: 560px; }
}

@media (prefers-reduced-motion: reduce) {
  .sheet, .sheet.open, .coach, .book, .btn, .wk b { transition: none; }
  .sk { animation: none; }
}
