/* pnt-web shared theme — link as /_shared/style.css.
 *
 * Responsive by construction: an agent writes plain HTML with these classes and it works from a
 * 360px phone to a 27" monitor. Deliberately NO breakpoints for agents to reason about — the
 * layout primitives use intrinsic sizing (auto-fit/minmax, clamp) so they reflow on their own.
 * Light/dark aware, no external fonts, print-friendly.
 */

:root {
  color-scheme: light dark;

  --bg: #ffffff;
  --fg: #16181d;
  --dim: #6b7280;
  --line: #e5e7eb;
  --card: #fbfbfc;
  --card-hover: #f4f5f7;
  --accent: #2f7d55;
  --code-bg: #f3f4f6;

  /* Fluid type: small end for phones, large end for desktop, no media query needed. */
  --step--1: clamp(0.82rem, 0.79rem + 0.15vw, 0.9rem);
  --step-0:  clamp(1rem, 0.96rem + 0.2vw, 1.08rem);
  --step-1:  clamp(1.12rem, 1.05rem + 0.35vw, 1.3rem);
  --step-2:  clamp(1.3rem, 1.16rem + 0.7vw, 1.7rem);
  --step-3:  clamp(1.55rem, 1.3rem + 1.2vw, 2.25rem);

  /* Reading column for prose; .wide pages get more room for tables/dashboards. */
  --measure: 46rem;
  --measure-wide: 72rem;
  --gap: clamp(0.75rem, 0.6rem + 0.6vw, 1.25rem);
  --pad: clamp(1rem, 0.7rem + 1.4vw, 2rem);
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --fg: #e8eaed;
    --dim: #9aa1ac;
    --line: #2a2e35;
    --card: #1a1d22;
    --card-hover: #21252b;
    --accent: #5fbf8b;
    --code-bg: #22262c;
  }
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; animation: none !important; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic",
               "Noto Sans KR", system-ui, sans-serif;
  font-size: var(--step-0);
  line-height: 1.65;
  word-break: keep-all;              /* Korean wraps between words, not mid-word */
  overflow-wrap: break-word;
  -webkit-tap-highlight-color: transparent;
}

/* Page shell. `main.wide` for table/dashboard pages; plain `main` for prose.
   Respects the iPhone notch/home-bar via safe-area insets. */
main {
  max-width: var(--measure);
  margin-inline: auto;
  padding: calc(var(--pad) * 0.8) max(var(--pad), env(safe-area-inset-left)) 3rem;
  padding-bottom: max(3rem, env(safe-area-inset-bottom));
}
main.wide { max-width: var(--measure-wide); }

header { margin: 0.25rem 0 var(--gap); }
h1 { font-size: var(--step-3); line-height: 1.25; margin: 0 0 0.3rem; letter-spacing: -0.015em; }
h2 { font-size: var(--step-2); line-height: 1.3; margin: 2rem 0 0.5rem; }
h3 { font-size: var(--step-1); margin: 1.4rem 0 0.35rem; }
.sub { color: var(--dim); margin: 0; font-size: var(--step--1); }
p, li { font-size: var(--step-0); }
p { margin: 0.7rem 0; }
ul, ol { padding-left: 1.3rem; }
li + li { margin-top: 0.25rem; }

a { color: var(--accent); text-underline-offset: 2px; }
/* Comfortable tap targets on phones without affecting inline links in prose. */
nav a, .card, .list a, footer a { min-height: 44px; display: inline-flex; align-items: center; }

code, kbd {
  background: var(--code-bg); padding: 0.1em 0.35em; border-radius: 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.88em;
}
pre {
  background: var(--code-bg); padding: 0.8rem 1rem; border-radius: 10px;
  overflow-x: auto;                  /* code scrolls itself; the page never scrolls sideways */
  -webkit-overflow-scrolling: touch;
}
pre code { background: none; padding: 0; }
hr { border: none; border-top: 1px solid var(--line); margin: 2rem 0; }
blockquote { margin: 1rem 0; padding: 0.1rem 1rem; border-left: 3px solid var(--line); color: var(--dim); }
img, svg, video { max-width: 100%; height: auto; border-radius: 8px; }

/* ── Layout primitives — these are the responsive part ─────────────────────────
 * .grid            auto-fits as many columns as fit; 1 column on a phone, N on desktop.
 * .grid.two/.three cap the column count on wide screens.
 * .row             horizontal on desktop, stacks on narrow — no media query.
 * Sizes use min(100%, X) so a card never overflows a narrow viewport. */
.grid {
  display: grid;
  gap: var(--gap);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr));
  margin: var(--gap) 0;
}
.grid.two   { grid-template-columns: repeat(auto-fit, minmax(max(min(100%, 20rem), calc((100% - var(--gap)) / 2)), 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(max(min(100%, 13rem), calc((100% - var(--gap) * 2) / 3)), 1fr)); }
.row { display: flex; flex-wrap: wrap; gap: var(--gap); align-items: flex-start; }
.row > * { flex: 1 1 min(100%, 15rem); }

.box {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0.9rem 1rem; background: var(--card);
}
.note {
  border-left: 3px solid var(--accent); padding: 0.6rem 1rem; background: var(--card);
  border-radius: 0 8px 8px 0; margin: var(--gap) 0;
}
.badge {
  display: inline-block; padding: 0.1rem 0.5rem; border-radius: 999px;
  background: var(--code-bg); color: var(--dim); font-size: var(--step--1);
}

/* Stat tiles — reflow 1→2→4 across widths on their own. */
.stats {
  display: grid; gap: var(--gap); margin: var(--gap) 0;
  /* At most 4 across, however wide the screen — thinner tiles just look like noise. */
  grid-template-columns: repeat(auto-fit, minmax(max(min(100%, 9rem), calc((100% - var(--gap) * 3) / 4)), 1fr));
}
.stat { border: 1px solid var(--line); border-radius: var(--radius); padding: 0.8rem 0.9rem; background: var(--card); }
.stat b { display: block; font-size: var(--step-2); line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat span { color: var(--dim); font-size: var(--step--1); }

/* Cards / list links (also used by the site index). */
.card {
  display: flex; gap: 0.75rem; align-items: flex-start;
  padding: 0.85rem 1rem; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card); color: inherit; text-decoration: none; margin: 0;
  transition: border-color 0.15s, background 0.15s;
}
.card:hover { border-color: var(--accent); background: var(--card-hover); }
.card .emoji { font-size: 1.5rem; line-height: 1.2; flex: none; }
.card .body { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.card strong { font-size: var(--step-0); }
.card .desc, .card .meta { color: var(--dim); }
.card .desc { font-size: var(--step--1); }
.card .meta { font-size: 0.78rem; font-variant-numeric: tabular-nums; }
.list { display: grid; gap: 0.5rem; }

/* Timeline — good for itineraries and schedules. Time sits beside the entry on desktop and
   above it on a phone, via one intrinsic column definition. */
.timeline { display: grid; gap: 0.6rem; margin: var(--gap) 0; }
.timeline > li, .timeline > div {
  display: grid; gap: 0.15rem 0.9rem;
  grid-template-columns: minmax(0, 1fr);
  padding-bottom: 0.6rem; border-bottom: 1px solid var(--line);
  list-style: none;
}
.timeline time { color: var(--accent); font-weight: 600; font-variant-numeric: tabular-nums; }
@supports (grid-template-columns: subgrid) {
  @media (min-width: 30rem) {
    .timeline > li, .timeline > div { grid-template-columns: 5.5rem minmax(0, 1fr); }
    .timeline time { grid-row: span 2; }
  }
}

/* ── Tables ────────────────────────────────────────────────────────────────────
 * Default: wrap in <div class="scroll"> and a wide table scrolls inside its own box.
 * Optional: add class="stack" plus data-label on each cell and it becomes stacked
 * label/value rows on phones — nicer than sideways scrolling for long tables. */
.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: var(--gap) 0; }
table { border-collapse: collapse; width: 100%; font-size: var(--step--1); }
caption { text-align: left; color: var(--dim); font-size: var(--step--1); padding-bottom: 0.4rem; }
th, td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--dim); font-weight: 600; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:last-child td { border-bottom: none; }

@media (max-width: 34rem) {
  table.stack thead { display: none; }
  table.stack tr {
    display: block; border: 1px solid var(--line); border-radius: var(--radius);
    padding: 0.5rem 0.75rem; margin-bottom: 0.6rem; background: var(--card);
  }
  table.stack td { display: flex; justify-content: space-between; gap: 1rem; border: none; padding: 0.2rem 0; }
  table.stack td::before {
    content: attr(data-label); color: var(--dim); font-weight: 600; flex: none;
  }
  table.stack td.num { text-align: right; }
}

footer {
  margin-top: 2.5rem; padding-top: 1rem; border-top: 1px solid var(--line);
  color: var(--dim); font-size: var(--step--1);
}
footer p { font-size: var(--step--1); }
.backlink { display: inline-flex; margin-bottom: 0.75rem; font-size: var(--step--1); }

/* Printing a checklist or itinerary should look deliberate, not like a screenshot. */
@media print {
  :root { --bg: #fff; --fg: #000; --dim: #444; --line: #bbb; --card: #fff; --code-bg: #f2f2f2; }
  main { max-width: none; padding: 0; }
  .backlink, nav { display: none; }
  .card, .box, .stat, table.stack tr { break-inside: avoid; }
  a { color: inherit; text-decoration: none; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 0.8em; color: #555; }
}

/* Google Maps InfoWindow (see /_shared/pinmap.js).
   The bubble is drawn by Google and is always white, but its contents live in our DOM and so inherit
   our theme — in dark mode that produced light text on a white bubble, unreadable. Pin the colours to
   the bubble rather than the page. */
.gm-style .gm-style-iw-d,
.gm-style .gm-style-iw-c { color: #202124; }
.gm-style .gm-style-iw-c a { color: #1a73e8; }
