/* ===================================================================
   Tuner — Tomato Hero device aesthetic
   Strobe display + LED meter + string chips.
   =================================================================== */

:root {
  --bg:           #faf6f1;
  --bg-2:         #f3eee5;
  --surface:      #ffffff;
  --surface-2:    #faf6ed;
  --surface-3:    #eee7d8;
  --border:       #e8dfcc;
  --border-soft:  #f0e9da;
  --text:         #1f1a14;
  --text-2:       #5c5547;
  --text-3:       #6e6557;
  --text-faint:   #b5ac9b;

  --accent:       #e85f4d;
  --accent-2:     #d44a39;
  --accent-soft:  rgba(232, 95, 77, 0.10);
  --accent-glow:  rgba(232, 95, 77, 0.30);

  --tomato-from:  #ff6b4a;
  --tomato-to:    #e85f4d;
  --sage:         #5eb985;
  --sage-2:       #3a9d6f;
  --warning:      #f4d03f;
  --warning-2:    #d9b328;
  --warning-soft: rgba(244, 208, 63, 0.18);

  --device-shell-from: #f7f1e5;
  --device-shell-to:   #e8dfcc;
  --device-screen:     #fff4ec;     /* cream screen — light, not black */
  --device-screen-2:   #f6e6d6;
  --strobe-color:      rgba(232, 95, 77, 0.16);

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --r-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 24px 48px rgba(0,0,0,0.12);

  --font-ui: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI",
             "PingFang TC", "PingFang SC", "Hiragino Sans", "Noto Sans CJK",
             sans-serif;
  --font-mono: "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --font-display: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;

  --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
html, body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
select { font-family: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-2); }
ul, ol { list-style: none; }
[hidden] { display: none !important; }

.skip-link {
  position: absolute;
  left: -9999px; top: 0;
  background: var(--accent);
  color: #fff;
  padding: 10px 16px;
  font-weight: 600;
  border-radius: 0 0 var(--r-sm) 0;
  z-index: 1000;
}
.skip-link:focus { left: 0; }

.app {
  max-width: 920px;
  margin: 0 auto;
  padding: clamp(12px, 3vw, 24px) clamp(12px, 3vw, 24px) 80px;
}

/* ============ Top bar ============ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 4px 22px;
}
.brand {
  font-weight: 600;
  font-size: 15px;
  color: var(--text-2);
}
.brand:hover { color: var(--accent); }
.nav-link {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-3);
  padding: 6px 10px;
  border-radius: var(--r-sm);
}
.nav-link:hover { color: var(--accent); background: var(--surface-2); }
.topbar-right { display: flex; align-items: center; gap: 8px; }

.lang-switcher {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 6px 28px 6px 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 12 12' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 5l3 3 3-3' stroke='%237a7973' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 12px;
}
.lang-switcher:focus { border-color: var(--accent); }
.lang-switcher:focus:not(:focus-visible) { outline: none; }

.page-title {
  font-size: clamp(22px, 4vw, 30px);
  font-weight: 700;
  letter-spacing: -0.02em;
  text-align: center;
  margin-bottom: 6px;
}
.page-sub {
  text-align: center;
  font-size: 14px;
  color: var(--text-3);
  margin-bottom: 24px;
}

/* ============ Warning banners ============ */
.banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--r-md);
  margin-bottom: 16px;
  font-size: 14px;
  line-height: 1.5;
}
.banner-warning {
  background: var(--warning-soft);
  border: 1px solid var(--warning-2);
  color: #5a4a10;
}
.banner-icon {
  flex-shrink: 0;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--warning);
  color: #1f1a14;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}
.banner-body { flex: 1; }
.banner-body a {
  color: var(--accent-2);
  font-weight: 600;
  white-space: nowrap;
}

/* ============ Device shell ============ */
.tuner-device {
  background: linear-gradient(165deg, var(--device-shell-from) 0%, var(--device-shell-to) 100%);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: clamp(18px, 3.5vw, 28px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.8),
    inset 0 -2px 0 rgba(0, 0, 0, 0.04),
    var(--shadow-md);
}

/* ----- Header row with mode + tuning ----- */
.device-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.tuning-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.tuning-pill::before {
  content: "";
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}

.mode-toggle {
  display: inline-flex;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  padding: 3px;
  gap: 0;
}
.mode-btn {
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-3);
  border-radius: var(--r-pill);
  transition: background var(--transition), color var(--transition);
}
.mode-btn-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.mode-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ============ LED meter ============ */
.led-meter {
  display: flex;
  gap: 4px;
  justify-content: center;
  padding: 10px 0 14px;
}
.led {
  width: 14px;
  height: 8px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(0, 0, 0, 0.25);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transition: background 80ms, box-shadow 80ms;
}
.led-on.led-green {
  background: var(--sage);
  box-shadow: 0 0 8px rgba(94, 185, 133, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}
.led-on.led-yellow {
  background: var(--warning);
  box-shadow: 0 0 8px rgba(244, 208, 63, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}
.led-on.led-red {
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

/* ============ Strobe display screen ============ */
.strobe-stage {
  position: relative;
  background:
    radial-gradient(ellipse 90% 70% at 50% 35%, var(--device-screen) 0%, var(--device-screen-2) 100%);
  border-radius: 14px;
  padding: 28px 24px 22px;
  overflow: hidden;
  border: 1px solid rgba(40, 28, 20, 0.18);
  box-shadow:
    inset 0 2px 6px rgba(40, 28, 20, 0.28),
    inset 0 -1px 0 rgba(255, 255, 255, 0.5),
    inset 0 0 0 1px rgba(40, 28, 20, 0.10);
  min-height: 200px;
}

/* The strobe band itself: repeating stripes that scroll. */
.strobe-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(
      90deg,
      transparent 0px,
      transparent 22px,
      var(--strobe-color) 22px,
      var(--strobe-color) 44px
    );
  opacity: 0.7;
  animation: strobeScroll var(--strobe-duration, 0s) linear infinite;
  pointer-events: none;
}
.strobe-stage.strobe-idle::before {
  animation: none;
  opacity: 0.3;
}
.strobe-stage.strobe-stopped::before {
  animation-play-state: paused;
  opacity: 0.45;
}
.strobe-stage.strobe-left::before { animation-direction: reverse; }
.strobe-stage.strobe-right::before { animation-direction: normal; }

@keyframes strobeScroll {
  from { background-position: 0 0; }
  to   { background-position: 44px 0; }
}

/* Inner readout: note name + frequency + cent label */
.readout {
  position: relative;
  z-index: 1;
  text-align: center;
  color: var(--text-2);
}
.note-name {
  font-family: var(--font-display);
  font-size: clamp(54px, 12vw, 88px);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--accent-2);
  text-shadow:
    0 0 12px rgba(232, 95, 77, 0.25),
    0 1px 0 rgba(255, 255, 255, 0.45);
  font-variant-numeric: tabular-nums;
}
.freq-line {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text-3);
  margin-top: 6px;
  letter-spacing: 0.02em;
}
.freq-line .freq-value {
  color: var(--text);
  font-weight: 600;
}
.cent-row {
  margin-top: 12px;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 10px;
}
.cent-value {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}
.cent-unit {
  font-size: 13px;
  color: var(--text-3);
}
.cent-label {
  margin-top: 4px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-3);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.strobe-stage.strobe-stopped .note-name {
  color: var(--sage-2);
  text-shadow:
    0 0 14px rgba(58, 157, 111, 0.30),
    0 1px 0 rgba(255, 255, 255, 0.45);
}
.strobe-stage.strobe-stopped .cent-label {
  color: var(--sage-2);
}

/* ============ Mic toggle row ============ */
.mic-row {
  display: flex;
  justify-content: center;
  margin-top: 16px;
}
.mic-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  transition: border-color var(--transition), transform 80ms;
}
.mic-toggle::before {
  content: "";
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-faint);
}
.mic-toggle[data-running="true"]::before {
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.4; }
}
.mic-toggle:hover { border-color: var(--accent); }
.mic-toggle:active { transform: scale(0.97); }

/* ============ String buttons (chips) ============ */
.string-row {
  margin-top: 22px;
}
.string-row-label {
  display: block;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-3);
  font-weight: 700;
  text-align: center;
  margin-bottom: 12px;
}
.strings {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: clamp(6px, 1.5vw, 10px);
}
.string-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 8px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--r-md);
  font-weight: 700;
  color: var(--text);
  transition: border-color var(--transition), transform 80ms, background var(--transition);
}
.string-btn-note {
  font-size: clamp(16px, 3.5vw, 22px);
  font-family: var(--font-display);
  letter-spacing: -0.02em;
  color: var(--text);
}
.string-btn-hz {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-3);
  font-weight: 500;
}
.string-btn:hover {
  border-color: var(--accent);
  background: var(--surface-2);
}
.string-btn:active { transform: scale(0.96); }
.string-btn-active {
  background: var(--accent);
  border-color: var(--accent-2);
  color: #fff;
}
.string-btn-active .string-btn-note,
.string-btn-active .string-btn-hz {
  color: #fff;
}
.string-btn-target {
  border-color: var(--sage);
  background: rgba(94, 185, 133, 0.08);
}
.string-hint {
  text-align: center;
  font-size: 12px;
  color: var(--text-3);
  margin-top: 12px;
}
.kbd-hint {
  text-align: center;
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 4px;
}

/* ============ Info section ============ */
.info {
  margin-top: 48px;
  padding: 0 4px;
}
.info h2 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 8px;
  color: var(--text);
}
.info p {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-2);
  margin-bottom: 18px;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* ============ Footer ============ */
.site-footer {
  margin-top: 56px;
  padding-top: 22px;
  border-top: 1px solid var(--border-soft);
  text-align: center;
}
.site-footer-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
  font-size: 13px;
  color: var(--text-3);
}
.site-footer a { color: var(--text-2); }
.site-footer a:hover { color: var(--accent); }
.site-footer .sub {
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-3);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 480px) {
  .strings { grid-template-columns: repeat(3, 1fr); }
  .device-header { gap: 10px; }
  .strobe-stage { padding: 22px 16px 18px; min-height: 180px; }
  .note-name { font-size: 56px; }
}

/* ===== Tunings Hub ===== */
.tunings-hub {
  max-width: 720px;
  margin: 40px auto 0;
  padding: 32px 24px 36px;
  background: #faf6f1;
  border-radius: 16px;
  border: 1px solid #e8e0d5;
}

.hub-title {
  font-size: 20px;
  font-weight: 700;
  color: #1a1a1a;
  margin: 0 0 24px;
  letter-spacing: -0.3px;
}

.tuning-category {
  margin-bottom: 20px;
}

.tuning-category h3 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #9a8f85;
  margin: 0 0 8px;
}

.tuning-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tuning-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px 5px 10px;
  background: #f3eee5;
  border: 1px solid #ddd5c8;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  color: #2e2e2e;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}

.tuning-chip span {
  font-size: 11px;
  font-weight: 500;
  color: #9a8f85;
  font-family: 'SF Mono', 'Fira Mono', 'Consolas', monospace;
  letter-spacing: 0.03em;
}

.tuning-chip:hover {
  background: #e85f4d;
  border-color: #e85f4d;
  color: #fff;
}

.tuning-chip:hover span {
  color: rgba(255,255,255,0.82);
}

@media (max-width: 600px) {
  .tunings-hub {
    padding: 22px 16px 26px;
    margin: 28px auto 0;
    border-radius: 12px;
  }
  .hub-title { font-size: 17px; }
  .tuning-chip { font-size: 12px; padding: 5px 10px; }
}
/* ===== /Tunings Hub ===== */

/* ============ Focus visible ============ */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
button:focus:not(:focus-visible),
select:focus:not(:focus-visible),
input:focus:not(:focus-visible),
a:focus:not(:focus-visible) { outline: none; }
