/* Koh Chang Taxi — a ticket, not a brochure.
 *
 * The first version of this file was the Khao Yai stylesheet with the colours
 * and fonts swapped: 84% of the selectors were identical, the same photo hero,
 * the same section rhythm, the same fare cards and accordion. That is a template
 * skinned twice, which is the thing this whole job exists to stop.
 *
 * So this one starts from what the site is for. Nobody arrives here wanting a
 * landing page; they arrive wanting to know whether a flight landing at 15:00
 * still makes a boat. The page is therefore a planner first and a brochure
 * second, and it is dressed as the object the journey actually produces — a
 * cash ferry ticket bought at a window: perforated stubs, dashed rules, stamped
 * labels, everything in a typewriter face because that is what a ticket is set in.
 *
 * There is no photo hero. The photograph appears once, later, as a full-bleed
 * band between sections, where it does a different job.
 */

:root {
  color-scheme: light;

  --ink: #17211f;
  --ink-soft: #55625f;
  --sea: #0f5d63;          /* the deep teal of the crossing */
  --sea-dark: #0a3f44;
  --rust: #b4451f;         /* the ferry's painted hull. Deadlines only. */
  --rust-soft: #f7e3da;
  --stub: #f6f3ea;         /* ticket card stock */
  --stub-edge: #e3ded0;
  --paper: #fffdf8;
  --rule: #cfc9ba;
  --grey: #8b8578;

  --display: "Archivo", "IBM Plex Sans Thai", "Helvetica Neue", system-ui, sans-serif;
  --body: "Public Sans", "IBM Plex Sans Thai", system-ui, -apple-system, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --gap: clamp(1rem, 2.5vw, 1.85rem);
  --pad: clamp(1.1rem, 4.5vw, 3.5rem);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ink: #eceae2;
    --ink-soft: #a7b0ad;
    --sea: #64b6bd;
    --sea-dark: #9ad2d7;
    --rust: #e2825c;
    --rust-soft: #2e1a12;
    --stub: #171c1b;
    --stub-edge: #232b29;
    --paper: #0d1211;
    --rule: #2c3533;
    --grey: #8b9490;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: clamp(1rem, .96rem + .2vw, 1.06rem);
  line-height: 1.6;
}

h1, h2, h3 { font-family: var(--display); font-weight: 700; line-height: 1.12; margin: 0; letter-spacing: -.02em; }
p { margin: 0 0 1em; }
a { color: inherit; }
img { max-width: 100%; display: block; }

:lang(th) { line-height: 1.85; }
:lang(th) h1, :lang(th) h2, :lang(th) h3 { line-height: 1.4; letter-spacing: 0; }

:focus-visible { outline: 3px solid var(--rust); outline-offset: 2px; }

/* Everything numeric on this site is a time or a fare, and both want the
   typewriter. */
.t { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -.03em; }

.wrap { max-width: 68rem; margin-inline: auto; padding-inline: var(--pad); }

/* A stamped label: the small caps that appear on a printed ticket. */
.stamp {
  font-family: var(--mono); font-size: .7rem; font-weight: 500;
  letter-spacing: .16em; text-transform: uppercase; color: var(--grey);
  margin: 0 0 .6rem;
}

/* ── header: a slim bar, not a hero ─────────────────────────────────────── */
.bar { background: var(--sea-dark); color: #e7f1f1; }
.bar-in {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding-block: .9rem;
}
.bar-brand {
  display: inline-flex; align-items: center; gap: .55rem;
  font-family: var(--display); font-weight: 700; font-size: 1.05rem;
  color: #fff; text-decoration: none; margin-inline-end: auto; letter-spacing: -.02em;
}
.bar-brand img { height: 28px; width: auto; }
.bar a.lnk {
  font-family: var(--mono); font-size: .8rem; letter-spacing: .04em;
  text-transform: uppercase; text-decoration: none; color: #a8c9cb;
  padding-bottom: 2px; border-bottom: 1px dashed transparent;
}
.bar a.lnk:hover { color: #fff; border-bottom-color: var(--rust); }
.bar .lang { display: inline-flex; gap: .4rem; align-items: center; }
.bar .lang a { opacity: .5; text-decoration: none; }
.bar .lang a.on, .bar .lang a:hover { opacity: 1; }
.bar .lang img { height: 13px; width: auto; }
.bar-cta {
  font-family: var(--display); font-weight: 600; font-size: .88rem;
  background: var(--rust); color: #fff; text-decoration: none;
  padding: .42rem .9rem; border-radius: 1px;
}
.bar-cta:hover { background: #97381a; }

@media (max-width: 47.99rem) {
  .bar-in { display: grid; grid-template-columns: 1fr auto auto; gap: .5rem .7rem; }
  .bar-brand { grid-column: 1; grid-row: 1; margin-inline-end: 0; font-size: .98rem; }
  .bar .lang { grid-column: 2; grid-row: 1; }
  .bar-cta { grid-column: 3; grid-row: 1; }
  .bar-links {
    grid-column: 1 / -1; grid-row: 2; min-width: 0;
    display: flex; gap: 1.1rem; overflow-x: auto; scrollbar-width: none;
    margin: 0 calc(var(--pad) * -1); padding: 0 var(--pad) .1rem;
  }
  .bar-links::-webkit-scrollbar { display: none; }
  .bar a.lnk { white-space: nowrap; }
}
@media (min-width: 48rem) { .bar-links { display: contents; } }

/* ── the planner: the first thing on the page ───────────────────────────── */
.plan { background: var(--sea-dark); color: #eef5f5; padding-block: clamp(1.75rem, 5vw, 3.25rem) clamp(2.5rem, 6vw, 4rem); }
.plan h1 { color: #fff; font-size: clamp(1.6rem, 1.1rem + 2.2vw, 2.5rem); max-width: 20ch; }
.plan .sub { color: #b9d2d3; max-width: 52ch; margin-top: .8rem; font-size: 1.02rem; }
.plan .stamp { color: #7fb0b3; }

.plan-form {
  margin-top: 1.6rem;
  display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end;
}
.plan-field { display: flex; flex-direction: column; gap: .3rem; }
.plan-field label {
  font-family: var(--mono); font-size: .68rem; letter-spacing: .12em;
  text-transform: uppercase; color: #8ebabc;
}
.plan-field select, .plan-field input {
  font: inherit; font-family: var(--mono); font-size: 1rem;
  background: #0d3438; color: #fff;
  border: 1px solid #1d585e; border-radius: 1px; padding: .5rem .6rem;
}
.plan-field select { appearance: none; padding-right: 2rem;
  background-image: linear-gradient(45deg, transparent 50%, #7fb0b3 50%), linear-gradient(135deg, #7fb0b3 50%, transparent 50%);
  background-position: calc(100% - 15px) 55%, calc(100% - 10px) 55%;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
.plan-field select:focus, .plan-field input:focus { outline: none; border-color: var(--rust); }

/* ── the answer: a boarding-pass chain ──────────────────────────────────── */
.chain { margin-top: clamp(1.5rem, 4vw, 2.25rem); }
.chain-card {
  background: var(--stub); color: var(--ink);
  border-radius: 2px; overflow: hidden;
  box-shadow: 0 14px 40px -22px rgba(0,0,0,.55);
}
.chain-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 1rem;
  flex-wrap: wrap;
  padding: 1rem 1.25rem; background: var(--sea); color: #eaf6f6;
}
.chain-head b { font-family: var(--display); font-size: 1.12rem; }
.chain-head .verdict { font-family: var(--mono); font-size: .82rem; letter-spacing: .1em; text-transform: uppercase; }
.chain-card.is-miss .chain-head { background: var(--rust); }

/* the perforation between the pass and its stub */
.chain-perf {
  height: 0; border-top: 2px dashed var(--stub-edge);
  margin: 0 1.25rem; position: relative;
}
.chain-perf::before, .chain-perf::after {
  content: ""; position: absolute; top: -9px; width: 18px; height: 18px;
  border-radius: 50%; background: var(--sea-dark);
}
.chain-perf::before { left: -1.25rem; margin-left: -9px; }
.chain-perf::after { right: -1.25rem; margin-right: -9px; }

.chain-legs { list-style: none; margin: 0; padding: 1.1rem 1.25rem; display: grid; gap: 0; }
.chain-leg {
  display: grid; grid-template-columns: 4.5rem 1fr; gap: 0 1rem;
  padding: .6rem 0; border-bottom: 1px dotted var(--rule);
}
.chain-leg:last-child { border-bottom: 0; }
.chain-leg time { font-family: var(--mono); font-variant-numeric: tabular-nums; font-weight: 500; }
.chain-leg .what { font-size: .97rem; }
.chain-leg .note { display: block; color: var(--ink-soft); font-size: .86rem; }
.chain-leg.is-boat time { color: var(--sea); font-weight: 600; }
.chain-leg.is-warn time, .chain-leg.is-warn .what { color: var(--rust); }
.chain-foot {
  padding: 1rem 1.25rem; border-top: 2px dashed var(--stub-edge);
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
}
.chain-fare { font-family: var(--mono); font-size: .92rem; color: var(--ink-soft); }
.chain-fare b { font-family: var(--display); font-size: 1.3rem; color: var(--ink); }

.go {
  display: inline-flex; align-items: center; gap: .45rem;
  font-family: var(--display); font-weight: 600; font-size: .95rem;
  background: var(--sea); color: #fff; text-decoration: none;
  padding: .65rem 1.2rem; border-radius: 1px; border: 0; cursor: pointer;
}
.go:hover { background: var(--sea-dark); }
.go-quiet { background: transparent; color: var(--ink); border: 1px solid var(--rule); }
.go-quiet:hover { background: var(--stub-edge); color: var(--ink); }
.go-block { width: 100%; justify-content: center; }

/* ── body sections: dashed rules instead of solid slabs ─────────────────── */
.band { padding-block: clamp(2.5rem, 6vw, 4.25rem); }
.band + .band { border-top: 1px dashed var(--rule); }
.band h2 { font-size: clamp(1.5rem, 1.15rem + 1.6vw, 2.15rem); max-width: 24ch; }
.band > .wrap > p, .band .lede { color: var(--ink-soft); max-width: 60ch; }

/* the photograph, once, as a divider doing its own job */
.plate { position: relative; }
.plate img { width: 100%; height: clamp(13rem, 34vw, 24rem); object-fit: cover; }
.plate figcaption {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: clamp(1rem, 3vw, 1.75rem) var(--pad);
  background: linear-gradient(to top, rgba(10,25,26,.88), rgba(10,25,26,0));
  color: #e6efef; font-family: var(--mono); font-size: .84rem; letter-spacing: .02em;
}

/* ── the three legs, as a numbered run ──────────────────────────────────── */
.run { list-style: none; margin: 0; padding: 0; counter-reset: run; display: grid; gap: 0; }
.run li {
  counter-increment: run;
  display: grid; grid-template-columns: 2.5rem 1fr; gap: 0 1.15rem;
  padding: 1.15rem 0; border-bottom: 1px dashed var(--rule);
}
.run li:first-child { border-top: 1px dashed var(--rule); }
.run li::before {
  content: counter(run); font-family: var(--mono); font-size: 1.5rem; font-weight: 500;
  color: var(--stub-edge); line-height: 1;
}
.run li.mine::before { color: var(--sea); }
.run h3 { font-size: 1.08rem; margin-bottom: .3rem; }
.run p { margin: 0 0 .4rem; color: var(--ink-soft); font-size: .96rem; max-width: 62ch; }
.run p:last-child { margin-bottom: 0; }
.run .who {
  display: inline-block; margin-top: .5rem;
  font-family: var(--mono); font-size: .7rem; letter-spacing: .1em; text-transform: uppercase;
  padding: .18rem .5rem; border: 1px solid var(--rule); border-radius: 1px; color: var(--ink-soft);
}
.run li.mine .who { border-color: var(--sea); color: var(--sea); }

/* ── the timetable ──────────────────────────────────────────────────────── */
.sailings { display: flex; flex-wrap: wrap; gap: .4rem; margin: 0 0 1.4rem; padding: 0; list-style: none; }
.sailings li {
  font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: .95rem;
  padding: .4rem .6rem; border: 1px solid var(--rule); border-radius: 1px; background: var(--stub);
}
.sailings li em {
  font-style: normal; display: block; font-size: .62rem; letter-spacing: .08em;
  text-transform: uppercase; color: var(--grey); margin-top: .1rem;
}
.sailings li.cut { border-color: var(--sea); color: var(--sea); }
.sailings li.cut em { color: var(--sea); }
.sailings li.last { border-color: var(--rust); background: var(--rust-soft); color: #8c3416; }
.sailings li.last em { color: #a44a25; }

/* ── fares as a matrix, because that is what three origins by three cars is ─ */
.matrix { width: 100%; border-collapse: collapse; font-size: .96rem; }
.matrix caption { text-align: left; color: var(--ink-soft); font-size: .9rem; padding-bottom: .7rem; }
.matrix th, .matrix td { padding: .7rem .6rem; border-bottom: 1px dashed var(--rule); text-align: left; }
.matrix thead th {
  font-family: var(--mono); font-size: .7rem; letter-spacing: .1em; text-transform: uppercase;
  color: var(--grey); border-bottom: 1px solid var(--rule);
}
.matrix tbody th { font-family: var(--display); font-weight: 600; }
.matrix tbody th small { display: block; font-family: var(--body); font-weight: 400; color: var(--ink-soft); font-size: .82rem; }
.matrix td.fare { font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.matrix td.pick a {
  font-family: var(--display); font-weight: 600; font-size: .85rem;
  text-decoration: none; color: var(--sea); white-space: nowrap;
  border-bottom: 1px solid currentColor; padding-bottom: 1px;
}
.matrix td.pick a:hover { color: var(--rust); }
.scroll-x { overflow-x: auto; }

/* ── questions: plain, no accordion ─────────────────────────────────────── */
.ask { display: grid; gap: 1.6rem; }
@media (min-width: 54rem) { .ask { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 3rem; } }
.ask h3 { font-size: 1.02rem; margin-bottom: .35rem; }
.ask p { color: var(--ink-soft); font-size: .95rem; margin: 0; }

/* ── chapters ───────────────────────────────────────────────────────────── */
.shelf { display: grid; gap: .6rem; }
@media (min-width: 44rem) { .shelf { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.shelf a {
  display: grid; grid-template-columns: 2.6rem 1fr; gap: 0 .9rem;
  padding: .8rem 0; border-bottom: 1px dashed var(--rule); text-decoration: none; color: inherit;
}
.shelf a:hover h3 { color: var(--sea); }
.shelf .no { font-family: var(--mono); font-size: .9rem; color: var(--grey); }
.shelf h3 { font-size: .99rem; margin-bottom: .15rem; }
.shelf p { margin: 0; font-size: .86rem; color: var(--ink-soft); }

/* ── notes and warnings ─────────────────────────────────────────────────── */
.note { border-left: 2px solid var(--rule); padding: .1rem 0 .1rem 1rem; color: var(--ink-soft); font-size: .95rem; }
.note-warn { border-left-color: var(--rust); }
.note-warn strong { color: var(--rust); }

.duo { display: grid; gap: var(--gap); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 48rem) { .duo { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 56rem) { .trio { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* ── footer: one line of a ticket, not a four-column sitemap ────────────── */
.foot { background: var(--sea-dark); color: #b4cfd0; padding-block: clamp(2rem, 5vw, 3rem); font-size: .92rem; }
.foot a { color: #e2eded; text-decoration: none; border-bottom: 1px dashed rgba(255,255,255,.25); }
.foot a:hover { border-bottom-style: solid; }
.foot-top { display: flex; gap: 1.5rem; flex-wrap: wrap; align-items: baseline; justify-content: space-between; }
.foot-links { display: flex; gap: 1.1rem; flex-wrap: wrap; font-family: var(--mono); font-size: .8rem; letter-spacing: .04em; text-transform: uppercase; }
.foot-links a { border-bottom: 0; color: #a8c9cb; }
.foot-links a:hover { color: #fff; }
.foot-who { border-top: 1px dashed rgba(255,255,255,.2); margin-top: 1.5rem; padding-top: 1.35rem; max-width: 62ch; color: #9fbabb; }
.foot-end { margin-top: 1.2rem; font-family: var(--mono); font-size: .74rem; letter-spacing: .04em; color: #7fa0a2; display: flex; gap: 1rem; flex-wrap: wrap; justify-content: space-between; }

/* ── forms on the inner pages ───────────────────────────────────────────── */
.sheet { background: var(--stub); border: 1px solid var(--stub-edge); border-radius: 2px; padding: clamp(1.1rem, 3.5vw, 1.9rem); }
.f { margin-bottom: 1rem; }
.f > label, .f-label { display: block; font-family: var(--mono); font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: var(--grey); margin-bottom: .3rem; }
.f-hint { text-transform: none; letter-spacing: 0; font-family: var(--body); color: var(--ink-soft); }
.in, .sel, .ta {
  width: 100%; font: inherit; font-size: 1rem; color: var(--ink);
  background: var(--paper); border: 1px solid var(--rule); border-radius: 1px; padding: .58rem .7rem;
}
.ta { resize: vertical; min-height: 5rem; }
.sel { appearance: none; padding-right: 2.1rem;
  background-image: linear-gradient(45deg, transparent 50%, var(--grey) 50%), linear-gradient(135deg, var(--grey) 50%, transparent 50%);
  background-position: calc(100% - 16px) 55%, calc(100% - 11px) 55%;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
.in:focus, .sel:focus, .ta:focus { outline: none; border-color: var(--sea); box-shadow: 0 0 0 2px rgba(15,93,99,.15); }
.f-row { display: grid; gap: 0 var(--gap); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 34rem) { .f-row-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.opts { display: flex; gap: .4rem; flex-wrap: wrap; }
.opts button {
  font-family: var(--mono); font-size: .85rem; letter-spacing: .06em; text-transform: uppercase;
  padding: .5rem .85rem; background: var(--paper); color: var(--ink-soft);
  border: 1px solid var(--rule); border-radius: 1px; cursor: pointer;
}
.opts button:hover { border-color: var(--sea); }
.opts button.on { background: var(--sea); color: #fff; border-color: var(--sea); }

.rows { display: grid; gap: .4rem; }
.row {
  display: flex; align-items: baseline; justify-content: space-between; gap: 1rem;
  width: 100%; text-align: left; font: inherit; color: inherit;
  background: var(--paper); border: 1px solid var(--rule); border-radius: 1px;
  padding: .65rem .8rem; cursor: pointer;
}
.row:hover { border-color: var(--sea); }
.row.on { border-color: var(--sea); box-shadow: inset 2px 0 0 var(--sea); background: var(--stub); }
.row-name { font-family: var(--display); font-weight: 600; font-size: .95rem; }
.row-sub { display: block; color: var(--ink-soft); font-size: .84rem; }
.row-fare { font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }

.msg { border-radius: 1px; padding: .8rem .95rem; margin-bottom: 1rem; font-size: .95rem; }
.msg-ok { background: #e2eeee; border-left: 3px solid var(--sea); color: #143a3d; }
.msg-bad { background: var(--rust-soft); border-left: 3px solid var(--rust); color: #7d3115; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .msg-ok { background: #12241f; color: #cfe4e2; }
  :root:not([data-theme="light"]) .msg-bad { background: #2e1a12; color: #f0c0a6; }
}

.reach {
  display: flex; align-items: center; gap: .8rem;
  border: 1px solid var(--rule); border-radius: 1px; background: var(--stub);
  padding: .9rem 1.05rem; text-decoration: none;
}
.reach:hover { border-color: var(--sea); }
.reach b { font-family: var(--display); font-size: .98rem; display: block; }
.reach span { color: var(--ink-soft); font-size: .85rem; }

/* Turnstile is a fixed 300px iframe, wider than a form on a 320px phone. */
.cf-turnstile { max-width: 100%; overflow-x: auto; }

.spin {
  display: inline-block; width: 1em; height: 1em; margin-right: .45em;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: sp .7s linear infinite; vertical-align: -.15em;
}
@keyframes sp { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
  .spin { animation-duration: 1.6s !important; }
}
