/* Lost Pet Poster. Phone first; two columns once there's room. */
@font-face { font-family: Anton; src: url(fonts/anton.woff2) format('woff2'); font-display: block; }
@font-face { font-family: Archivo; src: url(fonts/archivo.woff2) format('woff2'); font-weight: 100 900; font-display: swap; }

:root {
  --ink: #111; --paper: #fff; --bg: #f3f1ec; --line: #d9d5cc; --muted: #6b665c;
  --lost: #d0101a; --found: #0b4ea2; --home: #137a36; --accent: var(--lost);
  --r: 12px; --tap: 48px;
  --sl: env(safe-area-inset-left); --sr: env(safe-area-inset-right);
  --st: env(safe-area-inset-top); --sb: env(safe-area-inset-bottom);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 17px/1.4 Archivo, system-ui, sans-serif; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
h2 { font: 800 15px/1.2 Archivo, sans-serif; text-transform: uppercase; letter-spacing: .06em; margin: 28px 0 10px; color: var(--muted); }

/* header */
.top { position: sticky; top: 0; z-index: 5; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px;
  padding: calc(10px + var(--st)) calc(16px + var(--sr)) 10px calc(16px + var(--sl)); background: var(--paper); border-bottom: 1px solid var(--line); }
.top h1 { margin: 0; font: 800 19px/1.2 Archivo, sans-serif; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top h1:first-child { grid-column: 1 / 3; }
.top .t { text-align: center; }
.mark { font-family: Anton, sans-serif; font-weight: 400; color: var(--lost); letter-spacing: .02em; }
.top .link, .top .back { text-decoration: none; font-weight: 600; color: var(--muted); min-height: var(--tap); display: flex; align-items: center; }
.top .back { color: var(--ink); }

/* home */
.home, .help { max-width: 640px; margin: 0 auto; padding: 20px calc(16px + var(--sr)) calc(40px + var(--sb)) calc(16px + var(--sl)); }
.lede { font-size: 19px; margin: 6px 0 20px; }
.start { display: grid; gap: 12px; }
.big { display: grid; text-align: left; gap: 2px; padding: 20px; border: 0; border-radius: var(--r); color: #fff; cursor: pointer; min-height: 88px; }
.big b { font: 400 32px/1 Anton, sans-serif; letter-spacing: .01em; text-transform: uppercase; }
.big span { opacity: .9; }
.big.lost { background: var(--lost); }
.big.found { background: var(--found); }
.saved { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.saved a { display: grid; grid-template-columns: 64px 1fr; gap: 14px; align-items: center; padding: 10px; background: var(--paper);
  border: 1px solid var(--line); border-radius: var(--r); text-decoration: none; }
.saved img, .nothumb { width: 64px; height: 83px; object-fit: cover; border: 1px solid var(--line); background: #eee; display: block; }
.saved b { display: block; font-size: 18px; }
.saved small { display: inline-block; color: var(--muted); margin-right: 8px; }
.saved .mode { font-weight: 800; text-transform: uppercase; font-size: 12px; letter-spacing: .05em; }
.mode.lost { color: var(--lost); } .mode.found { color: var(--found); } .mode.home { color: var(--home); }
.fine { color: var(--muted); font-size: 14px; margin-top: 28px; }

/* editor */
.tabs { position: sticky; top: calc(69px + var(--st)); z-index: 4; display: grid; grid-template-columns: 1fr 1fr; background: var(--paper);
  border-bottom: 1px solid var(--line); padding: 0 calc(8px + var(--sr)) 0 calc(8px + var(--sl)); }
.tabs button { border: 0; background: none; min-height: var(--tap); font-weight: 700; color: var(--muted); border-bottom: 3px solid transparent; cursor: pointer; }
.tabs [aria-selected=true] { color: var(--ink); border-bottom-color: var(--accent); }
.edit { max-width: 640px; margin: 0 auto; padding: 12px calc(16px + var(--sr)) calc(110px + var(--sb)) calc(16px + var(--sl)); }
.edit[data-mode=found] { --accent: var(--found); }
.edit[data-mode=home] { --accent: var(--home); }
.edit[data-pane=form] .out, .edit[data-pane=out] .form { display: none; }
.edit:not([data-mode=lost]) .lost-only, .edit:not([data-mode=found]) .found-only { display: none; }
[hidden] { display: none !important; }

fieldset { border: 0; margin: 18px 0 0; padding: 16px; background: var(--paper); border-radius: var(--r); border: 1px solid var(--line); min-width: 0; }
legend { float: left; width: 100%; padding: 0; margin: 0 0 12px; font: 800 15px/1.2 Archivo, sans-serif; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
fieldset > :not(legend) { clear: both; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.grid > .f { grid-column: 1 / -1; }
.grid > .f.half { grid-column: auto; }
.f { display: grid; gap: 5px; min-width: 0; }
.f > span { font-weight: 600; font-size: 15px; }
div.f { margin-top: 14px; }
.f small, .hint { color: var(--muted); font-size: 14px; display: block; }
.hint { margin-top: 8px; }
input:not([type]), input[type=text], input[type=tel], input[type=date], select, textarea {
  width: 100%; min-height: var(--tap); padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; font-size: 17px; min-width: 0; }
input[type=date] { -webkit-appearance: none; appearance: none; display: block; }
textarea { resize: vertical; line-height: 1.35; }
input:not([type=range]):focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
input[type=range] { width: 100%; accent-color: var(--accent); min-height: 36px; }
.check { display: flex; gap: 10px; align-items: center; min-height: var(--tap); font-weight: 600; margin-top: 8px; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); }

.seg { display: flex; background: #ebe8e1; border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { flex: 1; border: 0; background: none; border-radius: 8px; min-height: 42px; font-weight: 600; cursor: pointer; padding: 0 6px; white-space: nowrap; }
.seg [aria-pressed=true] { background: var(--paper); box-shadow: 0 1px 3px rgba(0, 0, 0, .18); color: var(--accent); font-weight: 800; }
.form > .seg button { min-height: 50px; font-size: 18px; }
.form > .seg [data-v=lost][aria-pressed=true] { color: var(--lost); }
.form > .seg [data-v=found][aria-pressed=true] { color: var(--found); }
.form > .seg [data-v=home][aria-pressed=true] { color: var(--home); }

.warn, .cramped { background: #fff6d6; border: 1px solid #ecd27a; border-radius: 10px; padding: 8px 12px; font-size: 15px; margin: 12px 0 0; }

.frame { position: relative; border-radius: 8px; overflow: hidden; background: #e9e7e1; border: 2px solid var(--ink); }
.frame canvas { display: block; width: 100%; touch-action: none; cursor: grab; min-height: 120px; }
.frame-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--ink); font-weight: 700; font-size: 18px;
  border: 0; background: none; cursor: pointer; width: 100%; }
.frame.has .frame-empty { display: none; }
.sliders { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 8px; }

.row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.row.end { justify-content: flex-end; margin-top: 22px; }
.btn { min-height: var(--tap); padding: 0 18px; border-radius: 10px; border: 1.5px solid var(--ink); background: var(--paper); font-weight: 700; cursor: pointer; }
.btn.primary { background: var(--ink); color: #fff; }
.btn.ghost { border-color: var(--line); }
.btn.danger { border-color: var(--line); color: var(--lost); }
.btn.small { min-height: 40px; padding: 0 14px; width: 100%; }
.btn:disabled { opacity: .5; }
.out .row .btn { flex: 1; }

/* bottom bar on phones (details tab): a live mini poster and the way on to printing and sharing */
.nextbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; padding: 10px calc(16px + var(--sr)) calc(10px + var(--sb)) calc(16px + var(--sl));
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-top: 1px solid var(--line); }
.thumb { display: flex; align-items: center; gap: 14px; width: 100%; max-width: 608px; margin: 0 auto; padding: 6px 16px 6px 6px; min-height: 60px;
  background: var(--accent); color: #fff; border: 0; border-radius: 12px; cursor: pointer; font-weight: 800; font-size: 17px; text-align: left; }
.thumb canvas { width: 40px; height: auto; display: block; background: #fff; border-radius: 3px; flex: none; }

/* output */
.out h2:first-of-type { margin-top: 14px; }
.poster-view { display: block; width: 100%; max-width: 460px; margin: 12px auto 0; padding: 0; border: 0; background: none; cursor: zoom-in; }
.poster-view.land { max-width: 640px; }
.poster-view canvas, .cv canvas { display: block; box-shadow: 0 2px 12px rgba(0, 0, 0, .18); background: #fff; }
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.cards figure { margin: 0; display: grid; gap: 6px; align-content: start; }
.cards [data-card=story] { grid-row: span 2; }
.cards [data-card=wide] { grid-column: 1; }
.cards figcaption { font-size: 14px; color: var(--muted); font-weight: 600; }
.caption { min-height: 220px; font-size: 15px; }
.next { margin-top: 26px; padding: 14px 16px; border-radius: var(--r); background: #e7f3ea; border: 1px solid #b8dcc2; display: grid; gap: 10px; }
.next .btn { justify-self: start; border-color: var(--home); color: var(--home); }

/* full-size view */
#sheet { position: fixed; inset: 0; z-index: 20; background: rgba(20, 20, 20, .92); overflow: auto; padding: calc(12px + var(--st)) calc(12px + var(--sr)) calc(12px + var(--sb)) calc(12px + var(--sl)); }
#sheet .full canvas { display: block; width: 100%; max-width: 1100px; height: auto; margin: 40px auto 0; }
#sheet .close { position: fixed; top: calc(10px + var(--st)); right: calc(12px + var(--sr)); width: 48px; height: 48px; border-radius: 50%; border: 0;
  background: #fff; font-size: 30px; line-height: 1; cursor: pointer; }

#toast { position: fixed; left: 50%; bottom: calc(24px + var(--sb)); transform: translate(-50%, 30px); opacity: 0; z-index: 30; pointer-events: none;
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 10px; font-weight: 600; transition: .2s; max-width: calc(100% - 32px); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* help */
.help ol { padding-left: 22px; margin: 0; display: grid; gap: 8px; }
.contacts { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.contacts li { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; display: grid; gap: 3px; }
.contacts b a { color: var(--found); }
.contacts .tel { font: 400 24px/1.2 Anton, sans-serif; letter-spacing: .02em; text-decoration: none; color: var(--ink); justify-self: start; min-height: 40px; display: flex; align-items: center; }
.contacts small { color: var(--muted); }

/* room for two columns: details left, poster right, no tabs */
@media (min-width: 700px) {
  .tabs, .nextbar { display: none !important; }
  .edit { max-width: 1240px; display: grid; grid-template-columns: minmax(340px, 1fr) minmax(360px, 1fr); gap: 28px; align-items: start; padding-bottom: 60px; }
  .edit[data-pane] .form, .edit[data-pane] .out { display: block; }
  .out { position: sticky; top: calc(82px + var(--st)); max-height: calc(100vh - 96px - var(--st)); overflow: auto; padding: 0 6px 20px; }
  .poster-view { max-width: min(520px, max(240px, calc((100vh - 130px) * 0.77))); }
  .poster-view.land { max-width: min(640px, max(320px, calc((100vh - 130px) * 1.29))); }
  .home { max-width: 860px; }
  .cards { grid-template-columns: 1fr 1fr 1fr; }
  .cards [data-card=story] { grid-row: auto; }
  .cards [data-card=wide] { grid-column: auto; }
}
@media (min-width: 1100px) { body { font-size: 18px; } .big b { font-size: 38px; } .start { grid-template-columns: 1fr 1fr; } }
@media (max-width: 360px) { .grid { grid-template-columns: 1fr; } .grid > .f.half { grid-column: 1 / -1; } .seg button { font-size: 15px; } }

/* print: only the poster image, page size set by #page-size */
#print { display: none; }
@media print {
  body { background: #fff; }
  #app, #sheet, #toast { display: none !important; }
  #print { display: block; }
  #print img { display: block; width: 8.5in; height: 11in; }
  #print.a4 img { width: 210mm; height: 297mm; }
  #print.half img { width: 11in; height: 8.5in; }
}
