/* Dharitri Advertisement Booking — one stylesheet for every screen.
   Calm and plain for daily use: warm paper background, ink text, one ink-blue accent,
   red only for warnings. Instrument Sans (SIL Open Font Licence) is served from this
   application. Motion is limited to a short press on buttons. */

@font-face {
  font-family: "Instrument Sans";
  src: url("fonts/InstrumentSans.woff2") format("woff2-variations"), url("fonts/InstrumentSans.woff2") format("woff2");
  font-weight: 400 700;
  font-stretch: 75% 100%;
  font-display: swap;
}

:root {
  --paper: #f5f3ee;
  --surface: #ffffff;
  --sunk: #efece5;
  --ink: #1c2229;
  --ink-2: #47515d;
  --muted: #5f6672;            /* 4.9:1 or more on every background used */
  --line: #e1ddd3;
  --line-strong: #c9c2b4;
  --field-border: #8c8579;     /* form controls: 3.6:1 on white */
  --accent: #1e4b75;
  --accent-hover: #173b5d;
  --accent-soft: #e6eef6;
  --danger: #a8231b;
  --danger-soft: #fbeceb;
  --ok: #2c6637;
  --ok-soft: #e8f2e9;
  --warn-soft: #fdf4dc;
  --focus: #2b6cb0;
  --radius: 8px;
  --radius-sm: 6px;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --font: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 15.5px/1.5 var(--font);
  font-variant-numeric: tabular-nums;
}
a { color: var(--accent); text-underline-offset: 2px; text-decoration-thickness: 1px; }
::selection { background: #cfdcea; color: var(--ink); }
html { accent-color: var(--accent); caret-color: var(--accent); }
a:hover { color: var(--accent-hover); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .6rem; font-weight: 650; letter-spacing: -0.005em; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.08rem; }
h3 { font-size: .98rem; }
p { margin: 0 0 .75rem; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.num { text-align: right; white-space: nowrap; }

/* ---------------------------------------------------------------- top bar and frame */

.topbar {
  display: flex; align-items: center; gap: 1rem;
  padding: .55rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: baseline; gap: .6rem; text-decoration: none; color: var(--ink); margin-right: auto; }
.brand-mark { font-weight: 700; font-size: 1.12rem; letter-spacing: .01em; color: #b0221c; }
.brand-sub { font-size: .92rem; color: var(--ink-2); }
.who { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; min-width: 0; }
.who-name { font-weight: 600; font-size: .9rem; max-width: 22ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-level { font-size: .78rem; color: var(--muted); }
.top-links { display: flex; gap: .25rem; }
.top-links a { padding: .35rem .6rem; border-radius: var(--radius-sm); text-decoration: none; color: var(--ink-2); font-size: .92rem; }
.top-links a:hover { background: var(--sunk); color: var(--ink); }

.frame {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 1.75rem;
  max-width: 1240px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}
.frame-wide { max-width: none; }
.content { min-width: 0; }

.sidenav-fixed { position: sticky; top: 4.5rem; align-self: start; }
.nav-group { margin-bottom: 1.1rem; }
.nav-title { font-size: .74rem; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 0 0 .3rem .6rem; }
.sidenav ul { list-style: none; margin: 0; padding: 0; }
.sidenav a {
  display: block; padding: .38rem .6rem; border-radius: var(--radius-sm);
  color: var(--ink); text-decoration: none; font-size: .93rem;
}
.sidenav a:hover { background: var(--sunk); }
.sidenav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-fold { display: none; }

@media (max-width: 860px) {
  .frame { grid-template-columns: minmax(0, 1fr); gap: .75rem; padding: 1rem .9rem 2.5rem; }
  .sidenav-fixed { display: none; }
  .nav-fold { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
  .nav-fold summary { padding: .65rem .9rem; font-weight: 600; cursor: pointer; list-style: none; }
  .nav-fold summary::after { content: ""; float: right; width: .5rem; height: .5rem; margin-top: .35rem; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); }
  .nav-fold[open] summary::after { transform: rotate(-135deg); margin-top: .6rem; }
  .nav-fold .sidenav a { padding: .7rem .6rem; }
  .top-links a { padding: .65rem .55rem; }
  .who-name { max-width: 14ch; }
  .nav-fold[open] summary { border-bottom: 1px solid var(--line); }
  .nav-fold .sidenav { padding: .6rem .3rem .2rem; }
  .brand-sub { display: none; }
  .topbar { padding: .5rem .9rem; gap: .6rem; }
  .who-level { display: none; }
}

/* ---------------------------------------------------------------- panels, notices, facts */

.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.1rem 1.2rem; margin-bottom: 1.1rem;
}
.panel > :last-child { margin-bottom: 0; }
.panel-attention { border-color: #e2c46f; background: #fffcf2; }
.panel-quiet { background: transparent; }
.home-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.1rem; align-items: start; }
.home-grid .panel { margin: 0; }

.notice { padding: .65rem .85rem; border-radius: var(--radius-sm); margin: 0 0 1rem; border: 1px solid transparent; }
.notice-success { background: var(--ok-soft); color: var(--ok); border-color: #cfe4d2; }
.notice-error { background: var(--danger-soft); color: var(--danger); border-color: #f1cfcc; }
.notice-info { background: var(--accent-soft); color: var(--accent); border-color: #cfdcea; }
.notice-warn { background: var(--warn-soft); color: #6b4e00; border-color: #efdca6; }
.empty { color: var(--muted); padding: .9rem 0; }

.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: .35rem 1rem; margin: 0 0 .75rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }

.back { margin: -0.2rem 0 1rem; }
.back a { text-decoration: none; }

/* ---------------------------------------------------------------- forms */

.stack > * + * { margin-top: .85rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .85rem 1.25rem; }
.form-grid .full, .form-grid .actions { grid-column: 1 / -1; }
.form-narrow { grid-template-columns: minmax(0, 22rem); }
.form-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 640px) { .form-grid, .form-3 { grid-template-columns: minmax(0, 1fr); } }

.field { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.field > span, .legend { font-size: .88rem; font-weight: 600; color: var(--ink-2); }
.req::after { content: " *"; color: var(--danger); font-weight: 600; }
.hint { font-size: .84rem; color: var(--muted); font-weight: 400; }

input[type=text], input[type=password], input[type=date], input[type=number], input[type=email], input[type=search], select, textarea {
  font: inherit; color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--field-border); border-radius: var(--radius-sm);
  padding: .5rem .65rem; min-height: 2.75rem; width: 100%;
}
textarea { min-height: 4.5rem; resize: vertical; }
input:disabled, select:disabled, input[readonly] { background: var(--sunk); color: var(--ink-2); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--focus); }
input.is-invalid, select.is-invalid, textarea.is-invalid { border-color: var(--danger); background: #fffafa; }

fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem 1rem; margin: 0 0 1rem; background: var(--surface); min-width: 0; }
legend { padding: 0 .35rem; font-weight: 650; }

.choices { display: flex; flex-wrap: wrap; gap: .4rem .5rem; }
.choice {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .55rem .8rem; min-height: 2.75rem; border: 1px solid var(--field-border); border-radius: 999px;
  background: var(--surface); cursor: pointer; font-size: .93rem;
}
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.choice:has(input:disabled) { opacity: .6; cursor: not-allowed; }
.choice input { margin: 0; width: 1.05rem; height: 1.05rem; accent-color: var(--accent); }

.size-row { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; }
.size-row input { width: 5.6rem; }
.size-row .result { width: 7rem; }
.size-row .unit { color: var(--muted); font-size: .9rem; }

.dates { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: .55rem; }

/* ---------------------------------------------------------------- buttons */

.actions { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-top: .4rem; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font: 600 .95rem/1.2 var(--font);
  padding: .62rem 1rem; min-height: 2.75rem;
  border-radius: var(--radius-sm); border: 1px solid var(--field-border);
  background: var(--surface); color: var(--ink); text-decoration: none; cursor: pointer;
  transition: transform 120ms var(--ease-out), background-color 120ms ease;
}
.btn:hover { background: var(--sunk); color: var(--ink); }
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }
.btn-danger { background: var(--surface); border-color: #e3b3ae; color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); color: var(--danger); }
.btn-block { width: 100%; }
.btn-small { padding: .4rem .7rem; min-height: 2.25rem; font-size: .86rem; }
@media (pointer: coarse) { .btn-small { min-height: 2.75rem; } }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); text-decoration: underline; cursor: pointer; }

/* ---------------------------------------------------------------- steps of the booking */

.steps { display: flex; gap: .4rem; list-style: none; margin: -.2rem 0 1.2rem; padding: 0; flex-wrap: wrap; counter-reset: step; }
.steps li { counter-increment: step; display: flex; align-items: center; gap: .4rem; font-size: .88rem; color: var(--muted); }
.steps li::before {
  content: counter(step); display: inline-grid; place-items: center;
  width: 1.45rem; height: 1.45rem; border-radius: 50%;
  border: 1px solid var(--line-strong); font-size: .78rem; font-weight: 600; background: var(--surface);
}
.steps li + li::after { order: -1; content: ""; width: 1.4rem; height: 1px; background: var(--line-strong); margin-right: .1rem; }
.steps li[aria-current="step"] { color: var(--ink); font-weight: 600; }
.steps li[aria-current="step"]::before { background: var(--accent); border-color: var(--accent); color: #fff; }
.steps li.done::before { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
@media (max-width: 640px) {
  .steps li:not([aria-current="step"]) { font-size: 0; gap: 0; }
  .steps li:not([aria-current="step"])::before { font-size: .78rem; }
  .steps { gap: .35rem; flex-wrap: nowrap; }
  .steps li + li::after { display: none; }
}

.summary-line { display: flex; flex-wrap: wrap; gap: .35rem 1.2rem; font-size: .92rem; color: var(--ink-2); margin: 0 0 1rem; }
.summary-line b { color: var(--ink); font-weight: 600; }

/* ---------------------------------------------------------------- page list (choose a page) */

.pages { display: grid; grid-template-columns: repeat(auto-fill, minmax(4.4rem, 1fr)); gap: .5rem; margin: 0 0 1rem; }
.page-tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .15rem;
  aspect-ratio: 3 / 4; border: 1px solid var(--field-border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); text-decoration: none; font: inherit; cursor: pointer;
  transition: transform 120ms var(--ease-out);
}
.page-tile b { font-size: 1.15rem; }
.page-tile small { font-size: .7rem; color: var(--muted); }
.page-tile:hover { border-color: var(--accent); }
.page-tile:active { transform: scale(0.97); }
.page-tile[aria-current="true"] { border-color: var(--accent); background: var(--accent-soft); }
.page-tile.is-blocked { background: var(--sunk); color: var(--muted); border-style: dashed; border-color: var(--line-strong); }
.page-tile.is-blocked small { color: var(--danger); }

/* ---------------------------------------------------------------- the page drawing */

/* The page is drawn at the old scale, 20 pixels per cm: 658 x 1040 px = 32.9 x 52 cm.
   On narrow screens the whole sheet is scaled down to fit (placement.js converts positions). */
.sheet-wrap { width: 100%; overflow: hidden; }
.sheet-scale { transform-origin: 0 0; width: 658px; }
.sheet {
  position: relative; width: 658px; height: 1040px;
  background: #fbfaf7;
  background-image: linear-gradient(to right, rgba(30,75,117,.06) 1px, transparent 1px);
  background-size: 82.25px 100%;
  border: 1px solid var(--line-strong);
  box-shadow: 0 1px 2px rgba(0,0,0,.05);
  font-size: 9px; line-height: 1.25; overflow: hidden;
  touch-action: pan-y; user-select: none;   /* the page still scrolls under a finger; only the ad is dragged */
}
.sheet .page-no { position: absolute; right: 14px; top: 46%; font-size: 64px; font-weight: 700; color: rgba(168,35,27,.18); pointer-events: none; }
.sheet .masthead { position: absolute; left: 0; top: 0; width: 658px; height: 156px; background: #fff; border-bottom: 2px solid #000; display: grid; place-items: center; }
.sheet .masthead img { width: 200px; height: 87px; }
.sheet .band { position: absolute; left: 0; top: 0; width: 658px; height: 140px; border-bottom: 1px dashed var(--line-strong); }
.ad {
  position: absolute; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; overflow: hidden; padding: 2px; color: #fff; background: #858585;
}
.ad b { font-weight: 600; }
.ad-bw { background: #fff; color: #000; outline: 1px solid #000; outline-offset: -1px; }
.ad-mine {
  background: #f7d7ee; color: #3d1430; outline: 2px solid #b0307f; outline-offset: -2px;
  cursor: grab; z-index: 5; touch-action: none;
}
.ad-mine.is-fixed { cursor: pointer; }
.ad-mine.dragging { cursor: grabbing; box-shadow: 0 6px 18px rgba(0,0,0,.18); }
.place-layout { display: grid; grid-template-columns: minmax(0, 658px) minmax(0, 1fr); gap: 1.5rem; align-items: start; }
.place-side { position: sticky; top: 4.5rem; }
/* Narrower screens: the instructions and the button come first, above the page. */
@media (max-width: 1100px) { .place-layout { grid-template-columns: minmax(0, 1fr); } .place-side { position: static; order: -1; } .place-side .panel { margin-bottom: 0; } }
.place-status { min-height: 1.5rem; }

/* Print Dummy: colour ads pink-tinted, B/W ads grey, as the old dummy. */
.dummy .ad { color: #000; background: #fce7f9; outline: 1px solid #000; outline-offset: -1px; font-size: 10px; }
.dummy .ad-bw { background: #d4d4d4; }
.dummy-foot { display: flex; justify-content: space-between; gap: 1rem; width: 100%; max-width: 658px; font-size: 12px; margin-top: .4rem; }
.dummy-tip { display: none; }
.dummy .ad:hover .dummy-tip, .dummy .ad:focus .dummy-tip {
  display: block; position: absolute; left: 4px; top: 4px; z-index: 30; width: 260px; text-align: left;
  background: #fffbe6; color: #000; border: 1px solid #000; padding: 6px; font-size: 11px;
}

/* ---------------------------------------------------------------- tables */

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); margin-bottom: 1rem; }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th { text-align: left; font-weight: 600; font-size: .82rem; color: var(--ink-2); background: var(--sunk); padding: .55rem .7rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data td { padding: .55rem .7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:nth-child(even) td { background: #fbfaf8; }
table.data .id { font-weight: 600; white-space: nowrap; display: inline-block; padding: .2rem 0; }
.table-wrap:focus-visible { outline-offset: 0; }

.filters { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; margin-bottom: 1.1rem; }
.filters .field { min-width: 10rem; }
.filters .field-wide { min-width: 18rem; flex: 1; }
.pager { display: flex; flex-wrap: wrap; gap: .4rem .6rem; align-items: center; margin: 0 0 1rem; font-size: .9rem; }

.tag { display: inline-block; padding: .05rem .45rem; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--sunk); color: var(--ink-2); }
.tag-ok { background: var(--ok-soft); color: var(--ok); }
.tag-off { background: var(--danger-soft); color: var(--danger); }

.booking-id { font-size: 1.05rem; margin-bottom: .4rem; }
.booking-id b { display: inline-block; margin-left: .4rem; padding: .2rem .6rem; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--accent); font-size: 1.6rem; letter-spacing: .02em; }
.recap { margin: 0 0 1rem; }
.recap summary { cursor: pointer; font-weight: 600; }
.money { font-size: 1.15rem; }

/* ---------------------------------------------------------------- sign-in */

.signin-body { display: grid; place-items: center; min-height: 100vh; padding: 1.5rem; }
.signin { width: 100%; max-width: 23rem; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 1.8rem 1.6rem; }
.signin-logo { display: block; width: 150px; height: auto; margin-bottom: 1.1rem; }
.signin h1 { font-size: 1.3rem; margin-bottom: .25rem; }
.signin-sub { color: var(--muted); font-size: .92rem; margin-bottom: 1.3rem; }
.signin-help { color: var(--muted); font-size: .86rem; margin: 1.1rem 0 0; }

/* ---------------------------------------------------------------- printing */

@media print {
  body { background: #fff; }
  .topbar, .sidenav, .nav-fold, .no-print, h1, .notice { display: none !important; }
  .frame { display: block; padding: 0; max-width: none; }
  .sheet-scale { transform: none !important; }
  .sheet { border: 1px solid #000; box-shadow: none; background: #fff; }
  .dummy .ad { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  @page { size: A4 portrait; margin: 8mm; }
}

@media (prefers-reduced-motion: reduce) {
  .btn, .page-tile { transition: none; }
}
