/* GigDough — one column, results directly under the inputs; system fonts so it works offline.
   Colors come from theme.css (loaded first); never write a color here. */
:root {
  --radius: 10px;
  --page-width: 56rem;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Avenir Next Condensed", "Arial Narrow", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

/* Layout rules (display: grid/flex) must not override the hidden attribute. */
[hidden] { display: none !important; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }   /* the one px size: every other font-size is em */

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 1em;
  line-height: 1.5;
}

h1, h2 { margin: 0; line-height: 1.15; text-wrap: balance; }
h2 { font-size: 1.15em; }

.app {
  max-width: var(--page-width);
  margin: 0 auto;
  padding: 1.5rem max(1rem, env(safe-area-inset-right)) max(2rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  display: grid;
  gap: 1.5rem;
}

/* ---------- header */

.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 1rem;
}

h1 { font-family: var(--font-display); font-size: 2em; }

.subtitle { margin: 0.25rem 0 0; color: var(--muted); }

.total {
  display: grid;
  text-align: right;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.75rem 1.25rem;
}

.total .value {
  font-family: var(--font-display);
  font-size: 2em;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.label { font-size: 0.85em; color: var(--muted); }

/* ---------- fields */

.field { display: grid; gap: 0.35rem; min-width: 0; }

.field label { font-size: 0.95em; color: var(--muted); }

.req { color: var(--accent); }

input[type="text"], input[type="number"], input[type="email"], input[type="tel"], input[type="search"], input[type="date"], textarea, select {
  width: 100%;
  min-width: 0;   /* iPhone draws date boxes wider than the screen otherwise */
  font: inherit;
  font-size: 1em; /* 16px+ stops iPhone zooming in on focus */
  color: var(--fg);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.6rem 0.75rem;
  font-variant-numeric: tabular-nums;
}

/* iPhone ignores the width on its own date box: drop its built-in look so it fits like the other boxes */
input[type="date"] { -webkit-appearance: none; appearance: none; min-height: 2.95em; text-align: left; }
input[type="date"]::-webkit-date-and-time-value { text-align: left; }

input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; border-color: transparent; }

.input-box { position: relative; }
.input-box.money input { padding-left: 1.6rem; }
.input-box.percent input { padding-right: 2rem; }
.input-box.money::before,
.input-box.percent::after {
  position: absolute;
  top: 50%;
  translate: 0 -50%;
  color: var(--muted);
  pointer-events: none;
}
.input-box.money::before { content: "$"; left: 0.75rem; }
.input-box.percent::after { content: "%"; right: 0.75rem; }

.name-field input { max-width: 26rem; }
.hint { margin: 0; font-size: 0.85em; color: var(--muted); }
.warning { margin: 0; font-size: 0.9em; font-weight: 600; color: var(--bad); }
.disclaimer { margin: 0; font-size: 0.85em; color: var(--muted); }
.badge { margin: 0; font-size: 0.85em; font-weight: 600; color: var(--accent); }

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

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

.estimate { display: grid; gap: 1rem; }

.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; }

.btn {
  font: inherit;
  font-weight: 600;
  color: var(--soft-white);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.6rem 1.1rem;
  cursor: pointer;
}
.btn:hover:not(:disabled) { border-color: var(--muted); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn.danger { color: var(--white); background: var(--navy); border-color: var(--navy); }
.btn.small { padding: 0.35rem 0.75rem; font-size: 0.9em; }

/* ---------- tabs */

.costs { display: grid; gap: 1rem; }

.tabs {
  display: flex;
  gap: 0.25rem;
  overflow-x: auto;
  overscroll-behavior-x: none;   /* tab row scrolls but does not bounce or drag the page */
  border-bottom: 1px solid var(--line);
  scrollbar-width: thin;
}

.tabs button {
  font: inherit;
  font-size: 0.9em;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--muted);
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 0.6rem 0.9rem;
  cursor: pointer;
}
.tabs button:hover { color: var(--fg); }
.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.tabs button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ---------- show details */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: grid;
  gap: 1rem;
}

/* ---------- results */

.results {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 0.75rem;
  border-top: 3px solid var(--accent);
  padding-top: 1.5rem;
}

.metric {
  display: grid;
  gap: 0.25rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
}

.metric .value {
  font-family: var(--font-display);
  font-size: 1.6em;
  font-variant-numeric: tabular-nums;
}
.metric.profit .value { color: var(--good); }
.metric.loss .value { color: var(--bad); }

/* What if: drag the tickets sold */
.whatif { display: grid; gap: 0.6rem; }
.whatif h2 { margin: 0; }
.whatif input[type="range"] { width: 100%; accent-color: var(--accent); }
.whatif-out { margin: 0; font-size: 1.15em; }
.whatif-out .profit { color: var(--good); }
.whatif-out .loss { color: var(--bad); }

/* Print / PDF: only the show sheet, black on white */
.print-sheet { display: none; }
@media print {
  body > *:not(.print-sheet) { display: none !important; }
  body { background: var(--print-bg); color: var(--print-ink); }
  .print-sheet { display: block; font-size: 0.75em; }
  .print-sheet, .print-sheet * { color: var(--print-ink); background: none; }
  .print-sheet h1 { font-size: 1.6em; margin: 0 0 0.2em; }
  .print-sheet h2 { font-size: 1.1em; margin: 1.1em 0 0.3em; border-bottom: 1px solid var(--print-line); }
  .print-sheet table { width: 100%; border-collapse: collapse; }
  .print-sheet th, .print-sheet td { text-align: left; padding: 0.15em 0; font-weight: normal; }
  .print-sheet td { text-align: right; }
  .print-sheet .print-foot { margin-top: 1.5em; color: var(--print-muted); }
}

/* ---------- saved estimates */

.saved { display: grid; gap: 0.75rem; }

.saved-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.75rem; }
.saved-tools { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.empty { margin: 0; color: var(--muted); }

.saved-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }

.saved-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.65rem 0.9rem;
}
.saved-row.active { border-color: var(--accent); }

.saved-info { display: grid; min-width: 0; }
.saved-name { font-weight: 600; overflow-wrap: anywhere; }
.saved-meta { font-size: 0.85em; color: var(--muted); font-variant-numeric: tabular-nums; }
.saved-actions { display: flex; gap: 0.5rem; flex-shrink: 0; }

/* ---------- deal, splits, after the show */

select { appearance: auto; }
option { font-size: 1.035em; }   /* browsers that still draw their own list (Firefox, Windows) */
@supports (appearance: base-select) {   /* recent Chrome / Edge: bigger, readable list in the app's colors */
  select, select::picker(select) { appearance: base-select; }  select::picker(select) { background: var(--surface); color: var(--fg); border: 1px solid var(--line);
    border-radius: var(--radius); padding: .3rem; margin-top: .25rem; width: anchor-size(width); }   /* list as wide as the box, so long lines wrap */
  option { font-size: 1.035em; line-height: 1.25; padding: .4rem .8rem; border-radius: 6px; color: var(--grey-text); white-space: normal; overflow-wrap: anywhere; }
  option:hover, option:focus-visible { background: var(--accent); color: var(--accent-fg); }
  option:checked { font-weight: 600; }
}
.field.toggle label { display: flex; align-items: center; gap: 0.6rem; color: var(--fg); font-weight: 600; cursor: pointer; }
.field.toggle input { width: 1.2rem; height: 1.2rem; accent-color: var(--accent); flex-shrink: 0; }
.field.toggle { grid-column: 1 / -1; }
.metric .note { font-size: 0.8em; font-weight: 600; }

.splits, .settle { gap: 0.75rem; }
.split-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
.split-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 6.5rem auto auto;
  align-items: center;
  gap: 0.5rem;
}
.split-amount { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }

.settle-table-wrap { overflow-x: auto; overscroll-behavior-x: none; }
.settle-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.settle-table th, .settle-table td { padding: 0.45rem 0.5rem; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.settle-table th[scope="row"], .settle-table thead th:first-child { text-align: left; font-weight: 600; }
.settle-table thead th { font-size: 0.85em; color: var(--muted); font-weight: 600; }
.settle-table .up { color: var(--good); }
.settle-table .down { color: var(--bad); }

.saved-row { gap: 0.75rem; }
.saved-row .saved-info { flex: 1; }

@media (max-width: 30rem) {
  .split-row { grid-template-columns: minmax(0, 1fr) 6rem; }
  .split-amount { grid-column: 1; }
}

/* ---------- free trial and unlock */

.welcome { margin: 0; font-size: 0.9em; color: var(--muted); overflow-wrap: anywhere; }

.trial-bar {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.75rem;
  background: var(--surface); border: 1px solid var(--accent); border-radius: var(--radius); padding: 0.6rem 0.9rem;
  font-weight: 600;
}
.trial-bar .btn { text-decoration: none; }
.keep-bar { border-color: var(--line); font-weight: 400; }   /* data-safety tips: calmer than the trial bar */
.trial-actions { display: flex; align-items: center; gap: 0.75rem; }
.paywall { border: 2px solid var(--accent); }
.paywall .btn { text-decoration: none; }
/* After the trial: results and money tools are hidden until unlocked. Saved estimates and Export stay. */
body.locked .results, body.locked .splits, body.locked .settle, body.locked .total, body.locked .whatif, body.locked #print-btn { display: none; }
.linkish { font: inherit; color: inherit; background: none; border: 0; padding: 0; text-decoration: underline; cursor: pointer; }

/* ---------- club sharing */

.club { gap: 0.75rem; }
.club > div, .club-form { display: grid; gap: 0.75rem; }
.club-text { margin: 0; color: var(--muted); max-width: 40rem; }
.club .btn { text-decoration: none; }
textarea { resize: vertical; min-height: 4rem; }
.club-points { margin: 0; padding-left: 1.2rem; display: grid; gap: 0.5rem; color: var(--muted); }
.club-points strong { color: var(--fg); }
.club-license { display: grid; gap: 0.5rem; border-top: 1px solid var(--line); padding-top: 0.75rem; }
body.busy { cursor: progress; }

/* ---------- glossary + footer */

.glossary summary { cursor: pointer; font-weight: 600; }
.glossary dl { margin: 0.75rem 0 0; display: grid; gap: 0.5rem; }
.glossary dt { font-weight: 600; }
.glossary dd { margin: 0 0 0.25rem; color: var(--muted); }

.foot {
  display: grid;
  justify-items: center;
  text-align: center;
  gap: 1rem;
  font-size: 0.85em;
  color: var(--muted);
  border-top: 1px solid var(--line);
  padding-top: 1rem;
}
.foot .foot-links { font-size: 1.1765em; }   /* links a bit bigger: 16px */

/* ---------- dialog + toast */

dialog {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--fg);
  padding: 1.25rem;
  max-width: min(26rem, calc(100vw - 2rem));
}
dialog::backdrop { background: var(--black-45); }
dialog form { display: grid; gap: 0.75rem; }
dialog p { margin: 0; }
dialog h2 + .btn { justify-self: start; }   /* "Sign in with Google" at its own width, not full width */
dialog .hint:empty { display: none; }

.toast {
  position: fixed;
  left: 50%;
  bottom: max(1.25rem, env(safe-area-inset-bottom));
  translate: -50% 0;
  background: var(--fg);
  color: var(--bg);
  padding: 0.6rem 1rem;
  border-radius: var(--radius);
  font-weight: 600;
  max-width: calc(100vw - 2rem);
  box-shadow: 0 6px 20px var(--black-20);
}

@media (max-width: 30rem) {
  .grid { grid-template-columns: 1fr; }
  h1 { font-size: 1.6em; }
  .total { text-align: left; width: 100%; }
}

@media (prefers-reduced-motion: no-preference) {
  .btn, .tabs button { transition: border-color 0.15s, color 0.15s; }
}

.foot a { color: var(--muted); }

/* ---------- #log view: replaces the calculator while open */
.view { display: none; }
.view-mode main.app > :not(.view.on):not(.foot) { display: none !important; }
.view-mode .view.on { display: grid; gap: 1rem; }
.view-mode main.app { max-width: 125rem; }   /* same width as the header */
.log-table thead th { white-space: normal; vertical-align: bottom; }
.log-table th button { all: unset; cursor: pointer; }
.log-table th button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.log-table th[aria-sort] button::after { content: " \2193"; }
.log-table th[aria-sort="ascending"] button::after { content: " \2191"; }
.log-table tbody th button { all: unset; cursor: pointer; color: var(--fg); text-decoration: underline; text-underline-offset: 3px; }
.log-table tbody tr:hover { background: var(--surface-2); }
.log-table tfoot th, .log-table tfoot td { border-bottom: 0; }

/* Same fonts as the home page: poster headline, condensed caps for headings, buttons and tabs */
:root { --font-condensed: "Avenir Next Condensed", "Arial Narrow", "Roboto Condensed", sans-serif-condensed, sans-serif; }
h1 { font-family: var(--font-condensed); font-weight: 500; text-transform: uppercase; font-size: 2.4em; line-height: 0.95; }
h2, h3 { font-family: var(--font-condensed); font-weight: 400; text-transform: uppercase; }
h2 { font-size: 1.45em; }
.btn, .tabs button { font-family: var(--font-condensed); font-weight: 400; text-transform: uppercase; letter-spacing: 0.04em; }

/* ---------- fold-out forms: acts on the bill (venue version), one open at a time */
.performer-list { display: grid; gap: 0.6rem; }
.performer { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.performer > summary { list-style: none; cursor: pointer; padding: 0.8rem 1rem; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.3rem 0.8rem; }
.performer > summary::-webkit-details-marker { display: none; }
.performer > summary::after { content: "+"; margin-left: auto; font-size: 1.3em; color: var(--muted); line-height: 1; }
.performer[open] > summary::after { content: "\2212"; }
.performer .act-name { font-family: var(--font-condensed); text-transform: uppercase; font-size: 1.15em; }
.performer .act-role { color: var(--muted); font-size: 0.85em; }
.performer .act-deal { color: var(--muted); font-size: 0.9em; }
.performer-body { padding: 0 1rem 1rem; }
.performer-body .btn { justify-self: start; align-self: end; }

/* line headings: the bold words that start a line (as on the home and Help pages) */
strong.lh { color: var(--line-head); }

/* ---------- hover: one color across the site (--hover in theme.css), as on the home and Help pages */
a:not(.btn), .linkish { color: var(--accent); text-decoration: none; }
.foot a { color: var(--accent); }
a:not(.btn):hover, .linkish:hover { color: var(--hover); }
.log-table tbody th button:hover { color: var(--hover); }
.tabs button:not([aria-selected="true"]):hover { color: var(--hover); }
.btn:not(.primary):hover:not(:disabled) { border-color: var(--hover); color: var(--hover); }
.btn.danger:hover:not(:disabled), .btn.danger:focus-visible { color: var(--white); background: var(--danger); border-color: var(--danger); }
.btn.primary:hover:not(:disabled) { filter: brightness(1.12); }
.btn, .tabs button, a, .linkish { transition: color .15s ease, border-color .15s ease, filter .15s ease; }

/* "GigDough was updated. Refresh": shown when version.json is newer than the running app (checked on open and on return). */
.update-note { margin: 0; padding: .5rem 1rem; text-align: center; font-size: 0.9em; background: var(--surface-2); color: var(--fg); border-bottom: 1px solid var(--line); }

/* ---------- #calendar: saved shows by month (colors from theme.css) */
.cal-head { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.cal-month { margin: 0 0.4rem; font-size: 1.6em; min-width: 12rem; text-align: center; }
.cal-legend { display: flex; gap: 1.2rem; flex-wrap: wrap; margin: 0; font-size: 0.85em; color: var(--muted); }
.cal-key::before { content: ""; display: inline-block; width: 0.8rem; height: 0.8rem; border-radius: 2px; margin-right: 0.35rem; vertical-align: -1px; background: var(--key); }
.cal-key.confirmed, .cal-show.confirmed { --key: var(--accent); }
.cal-key.hold, .cal-show.hold { --key: var(--grey-text); }
.cal-key.done, .cal-show.done { --key: var(--navy); }
.cal-sum { display: flex; gap: 2rem; flex-wrap: wrap; }
.cal-sum span { display: block; font-size: 0.8em; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.cal-sum strong { font-family: var(--font-condensed); font-size: 1.5em; font-weight: 500; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.cal-dow, .cal-day { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.cal-dow { padding: 0.4rem 0.5rem; font-size: 0.8em; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.cal-day { min-height: 7rem; padding: 0.35rem 0.45rem; display: grid; align-content: start; gap: 0.3rem; min-width: 0; }
.cal-day.other { opacity: 0.35; }
.cal-day .n { font-size: 0.85em; color: var(--muted); }
.cal-day.today .n { color: var(--accent); }
.cal-show { all: unset; box-sizing: border-box; display: block; width: 100%; cursor: pointer; border-radius: 6px; padding: 0.35rem 0.45rem;
  background: var(--surface-2); border-left: 3px solid var(--key); color: var(--fg); font-size: 0.85em; line-height: 1.25; overflow: hidden; }
.cal-show b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-show span { color: var(--muted); font-size: 0.9176em; }
.cal-show span.neg { color: var(--bad); }
.cal-show:hover, .cal-show:focus-visible { outline: 2px solid var(--hover); outline-offset: 1px; }
.cal-list { display: none; list-style: none; margin: 0; padding: 0; gap: 0.5rem; }
@media (max-width: 45rem) {
  .cal-grid { display: none; }
  .cal-list { display: grid; }
  .cal-list .cal-show { font-size: 1em; padding: 0.7rem 0.8rem; }
  .cal-list .cal-show span { font-size: 0.78em; }
}

/* tablets: the whole form a bit bigger */
@media (min-width: 40.01rem) and (max-width: 64rem), (min-width: 40.01rem) and (max-width: 85.375rem) and (pointer: coarse) {   /* tablets, incl. big touch iPads up to 1366px */ html { font-size: 20px; } }
