/* Native American Flute Calculator */

:root {
  --bg: #faf6ef;
  --surface: #ffffff;
  --surface-2: #f3ece1;
  --ink: #2a1f17;
  --ink-2: #5b4a3d;
  --line: #e2d6c4;
  --line-2: #cdbca5;
  --cedar: #9a4a23;
  --cedar-ink: #7a3b1d;
  --cedar-soft: #f6e5d8;
  --sage: #2f6b5e;
  --sage-soft: #e3efe9;
  --amber: #a86a00;
  --amber-soft: #fbf0d9;
  --red: #a23b2a;
  --red-soft: #fae5e0;
  --wood: #e9cfa8;
  --wood-2: #d9b483;
  --bore: #7b5a3c;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 4px 16px rgba(60, 40, 20, .06);
  --radius: 12px;
  --serif: 'Literata', Georgia, 'Times New Roman', serif;
  --sans: 'Source Sans 3', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1612;
    --surface: #241d18;
    --surface-2: #2d251f;
    --ink: #f2e9de;
    --ink-2: #c9b8a6;
    --line: #3d332b;
    --line-2: #54463b;
    --cedar: #e08a5c;
    --cedar-ink: #f0a47b;
    --cedar-soft: #3a261b;
    --sage: #7cc4b0;
    --sage-soft: #1f322c;
    --amber: #e5b04f;
    --amber-soft: #33291a;
    --red: #f08f7d;
    --red-soft: #3a211c;
    --wood: #6b5139;
    --wood-2: #8a6a4b;
    --bore: #2a1f17;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1b1612; --surface: #241d18; --surface-2: #2d251f; --ink: #f2e9de; --ink-2: #c9b8a6;
  --line: #3d332b; --line-2: #54463b; --cedar: #e08a5c; --cedar-ink: #f0a47b; --cedar-soft: #3a261b;
  --sage: #7cc4b0; --sage-soft: #1f322c; --amber: #e5b04f; --amber-soft: #33291a; --red: #f08f7d;
  --red-soft: #3a211c; --wood: #6b5139; --wood-2: #8a6a4b; --bore: #2a1f17; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 17px/1.6 var(--sans);
}
img, svg { max-width: 100%; }
a { color: var(--cedar-ink); text-underline-offset: 2px; }
a:hover { color: var(--cedar); }
h1, h2, h3 { font-family: var(--serif); font-weight: 650; line-height: 1.2; letter-spacing: 0; margin: 0 0 .5em; }
h1 { font-size: clamp(1.9rem, 4vw, 2.6rem); }
h2 { font-size: clamp(1.35rem, 2.6vw, 1.7rem); margin-top: 1.6em; }
h3 { font-size: 1.15rem; margin-top: 1.4em; }
p, ul, ol { margin: 0 0 1em; }
code, kbd { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: .92em; }
kbd { border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 4px; padding: 0 .35em; background: var(--surface); }

.wrap { max-width: 1240px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 780px; }
.skip { position: absolute; left: -999px; top: 0; }
.skip:focus { left: 16px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 10; }

/* Header and footer */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px 24px; flex-wrap: wrap; padding-top: 12px; padding-bottom: 12px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font: 650 1.12rem/1.2 var(--serif); }
.brand-mark { width: 34px; height: 34px; flex: none; }
.brand-mark rect:first-child { fill: var(--wood-2); }
.brand-mark rect:last-child { fill: var(--ink); }
.brand-mark circle { fill: var(--ink); }
.site-nav { display: flex; gap: 4px 6px; flex-wrap: wrap; }
.site-nav a { color: var(--ink-2); text-decoration: none; font-weight: 600; padding: 6px 12px; border-radius: 999px; }
.site-nav a:hover { background: var(--surface-2); color: var(--ink); }
.site-nav a[aria-current="page"] { background: var(--cedar-soft); color: var(--cedar-ink); }
.site-footer { border-top: 1px solid var(--line); margin-top: 56px; padding: 24px 0 32px; color: var(--ink-2); font-size: .95rem; }
.site-footer p { margin: 0 0 .3em; }

/* Page intro */
.intro { padding: 32px 0 8px; }
.intro p.lede { font-size: 1.15rem; color: var(--ink-2); max-width: 760px; }
.kicker { display: block; font: 700 .8rem/1.4 var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--cedar-ink); margin-bottom: 10px; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card + .card { margin-top: 16px; }
.card h2 { margin-top: 0; font-size: 1.3rem; }
.card h3:first-child { margin-top: 0; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; margin-bottom: 8px; }
.card-head h2 { margin: 0; }
.muted { color: var(--ink-2); }
.small { font-size: .9rem; }

/* Calculator layout */
.calc { display: grid; grid-template-columns: minmax(300px, 380px) 1fr; gap: 24px; align-items: start; padding-top: 8px; }
.calc-inputs { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow: auto; }
.calc-results { min-width: 0; }
@media (max-width: 920px) {
  .calc { grid-template-columns: 1fr; }
  .calc-inputs { position: static; max-height: none; overflow: visible; }
}

/* Form controls */
.field { margin-bottom: 16px; }
.field > label, .field > .label { display: block; font-weight: 700; margin-bottom: 6px; }
.field .hint { display: block; font-size: .88rem; color: var(--ink-2); margin-top: 5px; line-height: 1.45; }
select, input[type="text"], input[type="number"] {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-2); border-radius: 8px; padding: 9px 11px; min-height: 44px;
}
select:focus, input:focus, button:focus-visible, a:focus-visible, summary:focus-visible { outline: 3px solid color-mix(in srgb, var(--cedar) 45%, transparent); outline-offset: 1px; }
input.overridden { border-color: var(--cedar); background: var(--cedar-soft); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg label { flex: 1 1 auto; position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; }
.seg span { display: block; text-align: center; padding: 9px 10px; border: 1px solid var(--line-2); border-radius: 8px; cursor: pointer; font-weight: 600; background: var(--surface); min-height: 44px; display: flex; align-items: center; justify-content: center; line-height: 1.2; }
.seg input:checked + span { background: var(--cedar-ink); border-color: var(--cedar-ink); color: #fff; }
.seg input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--cedar) 45%, transparent); }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 600; cursor: pointer; }
.check input { width: 20px; height: 20px; margin-top: 3px; accent-color: var(--cedar-ink); }
details.more { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 4px; }
details.more > summary { cursor: pointer; font-weight: 700; padding: 10px 0; color: var(--cedar-ink); list-style: none; display: flex; align-items: center; gap: 8px; }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::before { content: '+'; display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; border: 1px solid currentColor; font-size: 15px; line-height: 1; }
details.more[open] > summary::before { content: '\2212'; }
.subhead { font: 700 .82rem/1.3 var(--sans); text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); margin: 14px 0 10px; }
.per-hole { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.per-hole label { font-size: .85rem; font-weight: 600; display: block; margin-bottom: 3px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 8px; font: 700 .98rem/1.2 var(--sans); padding: 11px 16px; min-height: 44px; border-radius: 8px; border: 1px solid var(--cedar-ink); background: var(--cedar-ink); color: #fff; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--cedar); border-color: var(--cedar); color: #fff; }
.btn.secondary { background: var(--surface); color: var(--cedar-ink); }
.btn.secondary:hover { background: var(--cedar-soft); color: var(--cedar-ink); }
.btn.small { padding: 7px 12px; min-height: 36px; font-size: .9rem; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }
.linkish { background: none; border: 0; padding: 0; font: inherit; color: var(--cedar-ink); text-decoration: underline; cursor: pointer; }

/* Results */
.headline { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin: 4px 0 0; }
.stat { background: var(--surface-2); border-radius: 10px; padding: 12px 14px; }
.stat .k { display: block; font-size: .86rem; color: var(--ink-2); font-weight: 600; line-height: 1.35; }
.stat .v { display: block; font: 650 1.4rem/1.25 var(--serif); margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .d { display: block; font-size: .85rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.diagram { margin-top: 16px; overflow-x: auto; }
.diagram svg { display: block; width: 100%; height: auto; min-width: 640px; }
.diagram text { font-family: var(--sans); fill: var(--ink); }
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table.data { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.data th, table.data td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data th { font-size: .82rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-2); font-weight: 700; white-space: nowrap; }
table.data td.num { white-space: nowrap; }
table.data tr:last-child td { border-bottom: 0; }
table.data .dec { display: block; color: var(--ink-2); font-size: .85rem; }
.pill { display: inline-block; font-size: .78rem; font-weight: 700; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.pill.auto { background: var(--amber-soft); color: var(--amber); }

/* Fingering chart */
.fingering { display: flex; gap: 6px; align-items: center; }
.fingering .gap { width: 8px; }
.dot { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--ink); background: var(--ink); flex: none; }
.dot.open { background: transparent; }
.dot.thumb { border-style: dashed; }
.cents-ok { color: var(--sage); font-weight: 700; }
.cents-off { color: var(--amber); font-weight: 700; }

/* Notices */
.notice { border-radius: 10px; padding: 12px 14px; margin: 0 0 10px; border: 1px solid; }
.notice p { margin: 0; }
.notice p + p { margin-top: 6px; }
.notice.ok { background: var(--sage-soft); border-color: color-mix(in srgb, var(--sage) 35%, transparent); }
.notice.warn { background: var(--amber-soft); border-color: color-mix(in srgb, var(--amber) 35%, transparent); }
.notice.bad { background: var(--red-soft); border-color: color-mix(in srgb, var(--red) 35%, transparent); }
.notice.info { background: var(--surface-2); border-color: var(--line); }
.notice strong { display: block; margin-bottom: 2px; }

/* Learn pages */
.lesson { padding-bottom: 8px; }
.lesson-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; margin-top: 16px; }
.lesson-card { display: block; text-decoration: none; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.lesson-card:hover { border-color: var(--cedar); color: var(--ink); }
.lesson-card .num { font: 700 .8rem/1 var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--cedar-ink); }
.lesson-card h3 { margin: 8px 0 6px; }
.lesson-card p { margin: 0; color: var(--ink-2); font-size: .95rem; }
.prose { max-width: 760px; }
.prose li { margin-bottom: .4em; }
figure.shot { margin: 20px 0 28px; }
figure.shot img { display: block; width: 100%; height: auto; border: 1px solid var(--line-2); border-radius: 10px; box-shadow: var(--shadow); background: var(--surface); }
figure.shot.phone img { max-width: 360px; }
figure.shot figcaption { font-size: .92rem; color: var(--ink-2); margin-top: 8px; }
.steps { counter-reset: step; list-style: none; padding: 0; }
.steps > li { counter-increment: step; position: relative; padding-left: 44px; margin-bottom: 18px; }
.steps > li::before { content: counter(step); position: absolute; left: 0; top: 0; width: 30px; height: 30px; border-radius: 50%; background: var(--cedar-ink); color: #fff; font-weight: 700; display: grid; place-items: center; font-size: .95rem; }
.glossary dt { font-weight: 700; margin-top: 14px; }
.glossary dd { margin: 2px 0 0; color: var(--ink-2); }
.pager { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 36px; padding-top: 16px; border-top: 1px solid var(--line); }
.callout { background: var(--cedar-soft); border-radius: 10px; padding: 14px 16px; margin: 18px 0; }
.callout p:last-child { margin-bottom: 0; }

/* Template page */
.template-controls { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: end; }
.template-controls .field { margin: 0; min-width: 160px; }
.sheets { display: flex; flex-direction: column; align-items: center; gap: 24px; margin-top: 24px; }
.sheet { background: #fff; color: #000; box-shadow: var(--shadow); border: 1px solid var(--line-2); }
.sheet svg { display: block; }

/* Print */
@media print {
  @page { margin: 0.5in; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .site-header, .site-footer, .no-print, .calc-inputs, .skip { display: none !important; }
  .calc { display: block; }
  .card { box-shadow: none; border: 1px solid #bbb; break-inside: avoid; }
  .diagram svg { min-width: 0; }
  a { color: #000; }
}
.sheet svg { max-width: 100%; height: auto; }
@media print {
  body.print-template .intro { display: none !important; }
  body.print-template .wrap { max-width: none; padding: 0; }
  body.print-template .sheets { margin: 0; gap: 0; display: block; }
  body.print-template .sheet { box-shadow: none; border: 0; break-after: page; margin: 0; }
  body.print-template .sheet:last-child { break-after: auto; }
  body.print-template .sheet svg { max-width: none; }
}


/* Design code for the gadget */
.code-box textarea {
  width: 100%; font: 400 .86rem/1.5 ui-monospace, 'Cascadia Mono', Consolas, monospace; color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 8px; padding: 10px 12px;
  resize: vertical; word-break: break-all;
}
.pager-top { margin-top: 20px; padding-top: 0; padding-bottom: 12px; border-top: 0; border-bottom: 1px solid var(--line); }
