/* Circle of Fifths page — extends shared styles.css look */

.circle-shell {
  padding-bottom: 48px;
}

/*
 * Shared ../styles.css locks html/body { overflow: hidden } for the piano
 * one-screen trainer. Circle has no sticky keyboard — unlock document scroll
 * (and keep a touch-friendly overflow path on the shell for WebKit).
 */
html.circle-page,
body.circle-page,
html:has(.circle-shell),
body:has(.circle-shell) {
  height: auto;
  min-height: 100%;
  max-height: none;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}
body.circle-page,
body:has(.circle-shell) {
  min-height: 100dvh;
  touch-action: pan-y;
}
.app-shell.circle-shell {
  box-sizing: border-box;
  height: auto;
  max-height: none;
  min-height: 0;
  margin: 0 auto;
  padding-bottom: max(48px, env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
}
.app-shell.circle-shell > .topbar,
.app-shell.circle-shell > .circle-hero,
.app-shell.circle-shell > .circle-layout,
.app-shell.circle-shell > footer {
  flex: 0 0 auto;
}


.circle-hero {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px 20px;
  padding: 22px 0 8px;
  border-bottom: 1px solid rgba(29, 36, 31, 0.1);
}

.circle-hero h1 {
  margin: 0;
  font-size: clamp(22px, 4vw, 30px);
  letter-spacing: 0.02em;
}

.circle-subtitle {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.circle-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
}

.circle-toggle input {
  accent-color: var(--green);
  width: 16px;
  height: 16px;
}

.circle-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(260px, 0.85fr);
  gap: 22px;
  margin-top: 22px;
  align-items: start;
}

.circle-stage {
  padding: 12px 8px 18px;
  background: var(--card);
  border: 1px solid rgba(29, 36, 31, 0.1);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.circle-svg {
  display: block;
  width: min(100%, 560px);
  height: auto;
  margin: 0 auto;
  touch-action: manipulation;
}

.circle-ring {
  fill: none;
  stroke: var(--line);
  stroke-width: 1.5;
}
.circle-ring.outer { stroke: #d2c9ba; stroke-width: 2; }
.circle-ring.mid { stroke: #e4dccf; }
.circle-ring.inner { stroke: #ebe4d7; }

.spoke {
  stroke: rgba(29, 36, 31, 0.06);
  stroke-width: 1;
}

.center-disk {
  fill: #eef4ea;
  stroke: #d4e0d4;
  stroke-width: 1.5;
}
.center-title {
  fill: var(--green-dark);
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.08em;
}
.center-sub {
  fill: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.key-hit {
  fill: var(--card);
  stroke: var(--line);
  stroke-width: 1.5;
  cursor: pointer;
  transition: fill 120ms ease, stroke 120ms ease, filter 120ms ease;
}
.key-label {
  fill: var(--ink);
  font-size: 13px;
  font-weight: 800;
  pointer-events: none;
  letter-spacing: 0.01em;
}
.key-node.minor .key-label { font-size: 12px; font-weight: 700; }

.key-node.is-common .key-hit {
  stroke: var(--green);
  fill: #edf5ee;
}
.key-node.is-neighbor .key-hit {
  stroke: #c9a46a;
  fill: #fff6e8;
  stroke-width: 2;
}
.key-node.is-relative .key-hit {
  stroke: #6a8fbf;
  fill: #eaf1fb;
  stroke-width: 2.5;
}
.key-node.is-selected .key-hit {
  stroke: var(--orange);
  fill: #ffe8dc;
  stroke-width: 3;
  filter: drop-shadow(0 4px 10px rgba(233, 107, 58, 0.25));
}
.key-node.is-selected .key-label { fill: var(--green-dark); }

.key-hit:focus-visible {
  outline: 3px solid var(--orange);
  outline-offset: 3px;
}

.circle-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 16px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}
.circle-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.circle-legend .lg {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid transparent;
}
.circle-legend .lg.selected { background: #ffe8dc; border-color: var(--orange); }
.circle-legend .lg.relative { background: #eaf1fb; border-color: #6a8fbf; }
.circle-legend .lg.neighbor { background: #fff6e8; border-color: #c9a46a; }
.circle-legend .lg.common { background: #edf5ee; border-color: var(--green); }

.circle-side {
  display: grid;
  gap: 14px;
}

.detail-card,
.explain-card {
  padding: 18px 18px 16px;
  background: var(--card);
  border: 1px solid rgba(29, 36, 31, 0.1);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.detail-kicker {
  margin: 0 0 4px;
  color: var(--orange);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.detail-card h2,
.explain-card h2 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0.01em;
}

.detail-en {
  margin: 4px 0 14px;
  color: var(--muted);
  font-size: 13px;
}

.detail-grid {
  display: grid;
  gap: 10px;
  margin: 0;
}
.detail-grid div {
  display: grid;
  gap: 3px;
  padding: 10px 12px;
  background: var(--paper);
  border: 1px solid #ebe4d7;
  border-radius: 10px;
}
.detail-grid dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}
.detail-grid dd {
  margin: 0;
  color: var(--green-dark);
  font-size: 14px;
  font-weight: 700;
}

.detail-note {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.explain-card h2 {
  font-size: 15px;
  margin-bottom: 8px;
}
.explain-card ul {
  margin: 0;
  padding-left: 1.15em;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.6;
}
.explain-card li + li { margin-top: 6px; }
.explain-card strong { color: var(--green-dark); }

body.auth-locked .circle-layout,
body.auth-locked .circle-hero .circle-toggle {
  pointer-events: none;
  user-select: none;
  opacity: 0.42;
  filter: grayscale(0.25);
}

@media (max-width: 900px) {
  .circle-layout {
    grid-template-columns: 1fr;
  }
  .circle-svg {
    width: min(100%, 480px);
  }
}

/* OPPO Pad mini / narrow tablets */
@media (max-width: 720px) {
  .app-shell.circle-shell {
    width: min(1180px, calc(100% - 20px));
    height: auto;
    max-height: none;
    overflow-x: hidden;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
  }
  .topbar {
    flex-wrap: wrap;
    gap: 10px;
    min-height: auto;
    padding: 12px 0;
  }
  .brand-cluster {
    flex-wrap: wrap;
  }
  .circle-hero h1 { font-size: 22px; }
  .key-label { font-size: 12px; }
  .key-node.minor .key-label { font-size: 11px; }
}

@media (max-width: 420px) {
  .circle-svg { width: 100%; }
  .sibling-label { display: none; }
  .sibling-site { padding: 0 8px; min-height: 30px; }
}
