/* 19th Hole — a course architect's drafting palette.
   Light = paper. Dark = a rangefinder screen at dusk. */

:root {
  --bg:          #e7eae0;
  --surface:     #fbfbf5;
  --surface-2:   #f0f2e8;
  --ink:         #18231b;
  --ink-2:       #5d6d61;
  --ink-3:       #8c998f;
  --line:        #cfd5c5;
  --line-2:      #b9c1ad;
  --rule:        #9aa793;

  --rough-bg:    #dde4d2;
  --rough:       #5c8450;
  --fairway:     #86b96c;
  --putting:     #b3d98c;
  --putting-line:#7aa85e;
  --water:       #4a89ab;
  --sand:        #e8cf9c;
  --sand-line:   #c7a86f;

  --flag:        #c8401f;
  --shot:        #1f3d6b;
  --focus:       #1f3d6b;

  --par3:        #4a89ab;
  --par4:        #5c8450;
  --par5:        #b07d2a;

  --scrim:       #0b140c;
  --scrim-a:     0.14;
  --sat-line:    #ffffff;

  --radius:      10px;
  --shadow:      0 1px 2px rgba(24,35,27,.06), 0 6px 18px -10px rgba(24,35,27,.22);
  --sans:        'Archivo', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --display:     'Bricolage Grotesque', 'Archivo', ui-sans-serif, system-ui, sans-serif;
  --mono:        'DM Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:          #0f150f;
    --surface:     #171f18;
    --surface-2:   #1e281f;
    --ink:         #e6ede2;
    --ink-2:       #92a394;
    --ink-3:       #6a7a6d;
    --line:        #2a362b;
    --line-2:      #3a4a3c;
    --rule:        #4d5e50;

    --rough-bg:    #162017;
    --rough:       #2f5230;
    --fairway:     #46793e;
    --putting:     #5f9a4c;
    --putting-line:#7bb765;
    --water:       #2f6b8c;
    --sand:        #b29560;
    --sand-line:   #8a7247;

    --flag:        #ef5c33;
    --shot:        #7fb4ea;
    --focus:       #7fb4ea;

    --par3:        #5fa3c6;
    --par4:        #6fa35f;
    --par5:        #cfa04a;
    --scrim:       #06100a;
    --scrim-a:     0.20;
    --sat-line:    #ffffff;
    --shadow:      0 1px 2px rgba(0,0,0,.4), 0 8px 22px -12px rgba(0,0,0,.7);
  }
}

:root[data-theme="dark"] {
  --bg:#0f150f; --surface:#171f18; --surface-2:#1e281f;
  --ink:#e6ede2; --ink-2:#92a394; --ink-3:#6a7a6d;
  --line:#2a362b; --line-2:#3a4a3c; --rule:#4d5e50;
  --rough-bg:#162017; --rough:#2f5230; --fairway:#46793e;
  --putting:#5f9a4c; --putting-line:#7bb765; --water:#2f6b8c;
  --sand:#b29560; --sand-line:#8a7247;
  --flag:#ef5c33; --shot:#7fb4ea; --focus:#7fb4ea;
  --par3:#5fa3c6; --par4:#6fa35f; --par5:#cfa04a;
  --scrim:#06100a; --scrim-a:0.20; --sat-line:#ffffff;
  --shadow:0 1px 2px rgba(0,0,0,.4), 0 8px 22px -12px rgba(0,0,0,.7);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--display); font-weight: 700; margin: 0; text-wrap: balance; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.app { max-width: 1140px; margin: 0 auto; padding: 0 16px 56px; }

/* ------------------------------------------------------------------ topbar */

.bar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding-block: 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.bar__id { display: flex; align-items: center; gap: 11px; min-width: 0; flex: 1 1 240px; }

.mark {
  width: 34px; height: 34px; flex: none; border-radius: 7px;
  display: grid; place-items: center;
  background: var(--ink); color: var(--surface);
  font-family: var(--display); font-weight: 800; font-size: 14px; letter-spacing: -.02em;
}

.coursepick {
  appearance: none; -webkit-appearance: none;
  background: transparent; border: 0; padding: 0 20px 0 0; margin: 0;
  font-family: var(--display); font-size: 17px; font-weight: 700; letter-spacing: -.015em;
  cursor: pointer; max-width: 100%;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: right 7px center, right 2px center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.bar__meta { margin: 1px 0 0; font-size: 11.5px; color: var(--ink-3); letter-spacing: .01em; }

.tees { display: flex; gap: 5px; flex: none; }
.tee {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px 5px 8px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface);
  font-size: 12.5px; font-weight: 500; cursor: pointer;
  transition: border-color .12s, background .12s;
}
.tee:hover { border-color: var(--line-2); }
.tee[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: var(--surface); }
.tee i { width: 9px; height: 9px; border-radius: 2px; border: 1px solid rgba(0,0,0,.28); flex: none; }

.bar__tot { display: flex; gap: 16px; flex: none; }
.stat { text-align: right; }
.stat span { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .09em; color: var(--ink-3); }
.stat b { font-family: var(--mono); font-size: 16px; font-weight: 500; font-variant-numeric: tabular-nums; }

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

.views { display: flex; gap: 2px; padding-block: 12px 0; }
.views button {
  background: transparent; border: 0; border-bottom: 2px solid transparent;
  padding: 7px 12px; cursor: pointer; color: var(--ink-3);
  font-size: 13px; font-weight: 600; letter-spacing: .01em;
}
.views button:hover { color: var(--ink-2); }
.views button.is-on { color: var(--ink); border-bottom-color: var(--flag); }
.views .spacer { flex: 1; }

/* -------------------------------------------------------------------- rail */

.rail {
  display: flex; gap: 4px; overflow-x: auto; padding: 12px 0 6px;
  scrollbar-width: thin;
}
.rail button {
  flex: none; width: 46px; padding: 6px 0 7px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: 7px;
  display: grid; gap: 4px; justify-items: center;
  transition: border-color .12s, transform .12s;
}
.rail button:hover { border-color: var(--line-2); }
.rail button.is-on { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.rail .rn { font-family: var(--mono); font-size: 12px; font-variant-numeric: tabular-nums; }
.rail .rb { width: 24px; height: 3px; border-radius: 2px; background: var(--line-2); }
.rail .rp { font-size: 9.5px; color: var(--ink-3); letter-spacing: .05em; }

/* ------------------------------------------------------------------- views */

.view { padding-block: 18px; }
.holegrid { display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 1fr); gap: 26px; align-items: start; }

.map {
  margin: 0; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 10px; box-shadow: var(--shadow);
}
.map svg { display: block; width: 100%; height: auto; max-width: 100%; max-height: 62vh; margin: 0 auto; }
@media (max-width: 760px) { .map svg { max-height: 74vh; } }
.map figcaption {
  margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line);
  font-size: 10.5px; color: var(--ink-3); display: flex; gap: 10px; flex-wrap: wrap;
}
.key { display: inline-flex; align-items: center; gap: 4px; }
.key i { width: 8px; height: 8px; border-radius: 2px; }

.dg-rule { fill: var(--rule); font-family: var(--mono); font-size: 9px; }
.dg-mark { fill: var(--ink-3); font-family: var(--mono); font-size: 9.5px; }
/* over imagery, annotation text needs its own contrast */
.dg-on-sat { fill: #fff; paint-order: stroke; stroke: rgba(0,0,0,.55); stroke-width: 2.4px; stroke-linejoin: round; }

/* base-map control */
.mapbar { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.seg button {
  background: var(--surface); border: 0; padding: 5px 12px; cursor: pointer;
  font-size: 12px; font-weight: 600; color: var(--ink-3);
}
.seg button + button { border-left: 1px solid var(--line); }
.seg button.is-on { background: var(--ink); color: var(--surface); }
.seg button:disabled { opacity: .38; cursor: not-allowed; }
.seg button:disabled:hover { background: var(--surface); }
.mini-sel {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 7px;
  padding: 5px 8px; font-size: 12px; max-width: 100%;
}
.mapbar__grow { margin-left: auto; }
/* only meaningful full-size, where the hole header is off screen */
.mapbar__hole {
  font-family: var(--mono); font-size: 13px; font-variant-numeric: tabular-nums;
  color: var(--ink-2); letter-spacing: .04em; margin-left: 14px;
}
.mapbar__hole b { color: var(--ink); font-weight: 500; }

/* Full-size map. A fixed overlay rather than the Fullscreen API: the published
   Artifact runs in a sandboxed iframe that isn't granted fullscreen, and this
   behaves identically everywhere. */
.map.is-full {
  position: fixed; inset: 0; z-index: 200; margin: 0;
  border-radius: 0; border: 0; box-shadow: none;
  display: flex; flex-direction: column;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 14px calc(10px + env(safe-area-inset-bottom, 0px));
  background: var(--surface);
}
.map.is-full svg { max-height: none; height: 100%; flex: 1 1 auto; min-height: 0; }
.map.is-full figcaption { margin-top: 8px; }
body.map-open { overflow: hidden; }
@media (max-width: 760px) { .map.is-full svg { max-height: none; } }

.satwarn {
  margin: 0 0 9px; padding: 9px 11px; border-radius: 7px; font-size: 12px; line-height: 1.5;
  background: var(--flag-soft, var(--surface-2)); border: 1px solid var(--line-2); color: var(--ink-2);
}
.satwarn strong { color: var(--ink); }
#satUrl { width: 100%; background: var(--surface-2); border: 1px solid var(--line);
          border-radius: 7px; padding: 6px 8px; font-size: 12px; font-family: var(--mono); }
.dg-shot { fill: var(--surface); font-family: var(--mono); font-size: 10px; font-weight: 500; }

/* hole header */
.hh { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 4px; }
.hh__n { font-family: var(--display); font-size: 58px; line-height: .82; font-weight: 800; letter-spacing: -.04em; }
.hh__f { display: flex; gap: 20px; padding-bottom: 5px; }
.hh__f div span { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .09em; color: var(--ink-3); }
.hh__f div b { font-family: var(--mono); font-size: 21px; font-weight: 500; font-variant-numeric: tabular-nums; }
.hh__name { width: 100%; font-size: 13px; color: var(--ink-2); }

.pill {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 10.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
  border: 1px solid currentColor;
}
.p3 { color: var(--par3); } .p4 { color: var(--par4); } .p5 { color: var(--par5); }
.src-real { color: var(--shot); }
.src-schema { color: var(--ink-3); border-style: dashed; }

.note {
  margin: 14px 0 0; padding: 12px 14px; border-left: 2px solid var(--line-2);
  background: var(--surface-2); border-radius: 0 6px 6px 0;
  font-size: 13.5px; color: var(--ink-2);
}

/* shot ladder */
.ladder { margin-top: 18px; }
.ladder h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-3); font-weight: 600; font-family: var(--sans); }
.ladder ol { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.ladder li { display: grid; grid-template-columns: 22px 1fr auto auto; gap: 10px; align-items: baseline; padding: 9px 12px; background: var(--surface); }
.ladder .i { width: 18px; height: 18px; border-radius: 50%; background: var(--shot); color: var(--surface); display: grid; place-items: center; font-family: var(--mono); font-size: 10px; align-self: center; }
.ladder .c { font-weight: 600; font-size: 14px; }
.ladder .e { font-size: 11.5px; color: var(--ink-3); }
.ladder .d { font-family: var(--mono); font-size: 13px; font-variant-numeric: tabular-nums; }
.ladder .lead { font-size: 12px; color: var(--ink-2); margin: 8px 0 0; }
.ladder .empty { padding: 12px; background: var(--surface); border: 1px dashed var(--line-2); border-radius: 8px; font-size: 13px; color: var(--ink-3); }

.holenav { display: flex; gap: 8px; margin-top: 20px; }
.btn {
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 14px; cursor: pointer; font-size: 13px; font-weight: 500;
  transition: border-color .12s, background .12s;
}
.btn:hover { border-color: var(--line-2); background: var(--surface-2); }
.btn[disabled] { opacity: .4; cursor: default; }
.btn--go { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.btn--go:hover { background: var(--ink); opacity: .9; }
.btn--sm { padding: 5px 10px; font-size: 12px; }

/* course overview */
.course-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 12px; }
.mini { background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 8px; cursor: pointer; display: grid; gap: 6px; text-align: left; transition: border-color .12s; }
.mini:hover { border-color: var(--ink); }
.mini svg { display: block; width: 100%; height: auto; }
.mini__r { display: flex; justify-content: space-between; align-items: baseline; font-size: 11px; }
.mini__n { font-family: var(--display); font-weight: 700; font-size: 14px; }
.mini__y { font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--ink-3); }

/* scorecard */
.cardwrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table.card { border-collapse: collapse; width: 100%; min-width: 760px; font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 12.5px; }
table.card th, table.card td { padding: 7px 8px; text-align: center; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.card thead th { background: var(--surface-2); font-family: var(--sans); font-size: 10px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); font-weight: 600; position: sticky; top: 0; }
table.card th[scope="row"] { text-align: left; font-family: var(--sans); font-size: 11.5px; font-weight: 600; letter-spacing: .02em; }
table.card .tot { background: var(--surface-2); font-weight: 500; }
table.card tbody tr:hover td { background: var(--surface-2); }
table.card .teedot { display: inline-block; width: 8px; height: 8px; border-radius: 2px; border: 1px solid rgba(0,0,0,.25); margin-right: 6px; vertical-align: -1px; }
table.card input { width: 46px; background: transparent; border: 1px solid transparent; border-radius: 4px; padding: 2px 3px; text-align: center; font-family: var(--mono); font-size: 12.5px; }
table.card input:hover { border-color: var(--line); }
table.card input:focus { border-color: var(--focus); background: var(--bg); }

/* bag */
.bag-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.club { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; }
.club input.cn { flex: 1; min-width: 0; background: transparent; border: 0; font-weight: 600; font-size: 13.5px; padding: 2px 0; }
.club input.cy { width: 54px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; text-align: right; font-family: var(--mono); font-size: 13px; }
.club .u { font-size: 11px; color: var(--ink-3); }
.club .x { background: none; border: 0; color: var(--ink-3); cursor: pointer; padding: 2px 4px; font-size: 15px; line-height: 1; }
.club .x:hover { color: var(--flag); }

/* editor */
.editor { margin-top: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.editor > summary { padding: 10px 14px; cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--ink-2); list-style: none; display: flex; align-items: center; gap: 7px; }
.editor > summary::-webkit-details-marker { display: none; }
.editor > summary::before { content: '+'; font-family: var(--mono); color: var(--ink-3); }
.editor[open] > summary::before { content: '–'; }
.editor__body { padding: 0 14px 14px; display: grid; gap: 12px; }
.field { display: grid; gap: 4px; }
.field label { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); font-weight: 600; }
.field input, .field select, .field textarea {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px;
  padding: 7px 9px; font-size: 13px; width: 100%;
}
.field textarea { resize: vertical; min-height: 56px; font-family: var(--sans); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.hz-list { display: grid; gap: 6px; }
.hz { display: grid; grid-template-columns: auto auto 1fr auto; gap: 8px; align-items: center; background: var(--surface-2); border-radius: 7px; padding: 6px 8px; font-size: 12px; }
.hz select { background: var(--surface); border: 1px solid var(--line); border-radius: 5px; padding: 3px 5px; font-size: 12px; }
.hz input[type="range"] { width: 100%; accent-color: var(--focus); }

.sect-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.sect-head h2 { font-size: 19px; letter-spacing: -.01em; }
.sect-head p { margin: 0; font-size: 12.5px; color: var(--ink-3); }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }

.flag-note {
  margin-top: 26px; padding: 12px 14px; border-radius: 8px;
  background: var(--surface-2); border: 1px dashed var(--line-2);
  font-size: 12px; color: var(--ink-2); line-height: 1.55;
}
.flag-note strong { color: var(--ink); }

footer.foot { margin-top: 34px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 11.5px; color: var(--ink-3); display: grid; gap: 4px; }
footer.foot a { color: var(--ink-2); }

@media (max-width: 760px) {
  /* The bar wraps to two or three rows at this width. Sticky, it then covers the
     map controls directly beneath it and swallows taps meant for them. */
  .bar { position: static; }
  .holegrid { grid-template-columns: 1fr; gap: 18px; }
  .bar { gap: 12px; }
  .bar__tot { margin-left: auto; }
  .hh__n { font-size: 46px; }
  .row2 { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}


/* ---------------------------------------------------------- course aerial
   The whole course from above. Deliberately not per-hole: it is located by the
   course boundary, so it says where the course is and nothing about where any
   hole runs. A course whose holes are schematic still has schematic holes. */
.aerial { margin: 0 0 18px; }
.aerial__frame { margin-inline: auto; }
.aerial__frame {
  position: relative; overflow: hidden;
  border: 1px solid var(--line);
  background: var(--surface);
  /* aspect-ratio is set per course from the baked extent: a square frame would
     squash the imagery, and object-fit on each tile would distort them
     individually and break the seams between them. */
}
.aerial__tiles { position: absolute; display: grid; }
.aerial__tiles img { display: block; width: 100%; height: 100%; }
.aerial figcaption {
  margin-top: 8px; font-family: var(--mono); font-size: 10px;
  letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3);
  line-height: 1.7;
}

