/* ============================================================
   PTCG Case & Odds Lab — PTCGL Deck Code Converter
   Standalone stylesheet, loaded ONLY by converter.html.
   Shares the LP design language (platinum × deep navy × gold)
   but does not depend on home.css / styles.css.
   Hidden legacy sections (probability workbench) are kept in the
   DOM for converter.js bindings — the [hidden] guard below keeps
   them invisible regardless of other display rules.
   ============================================================ */

/* ---------- Font (self-hosted, CSP: default-src 'self') ---------- */
@font-face {
  font-family: "Space Grotesk";
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url("/assets/fonts/space-grotesk-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---------- Tokens ---------- */
:root {
  color-scheme: dark;
  --ink-950: #04080f;
  --ink-900: #060d16;
  --ink-800: #0a1828;
  --ink-700: #0e2236;
  --navy: #0f2a44;
  --plat-50: #fbfbfc;
  --plat-100: #f4f5f7;
  --plat-200: #e6e8ec;
  --plat-300: #cdd2d9;
  --plat-400: #9aa1ab;
  --plat-500: #5f6873;
  --gold: #f59e0b;
  --gold-bright: #fbbf24;
  --gold-deep: #b76e0b;
  --gold-pale: #ffe9b8;
  --blue-bright: #3ea2ef;
  --red-soft: #ff6b74;
  --maxw: 1080px;
  --pad-x: clamp(18px, 4.5vw, 36px);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --font-display: "Space Grotesk", "Hiragino Kaku Gothic ProN", "Hiragino Sans",
    "Yu Gothic UI", Meiryo, system-ui, sans-serif;
  --font-body: "Space Grotesk", "Hiragino Kaku Gothic ProN", "Hiragino Sans",
    "Yu Gothic UI", Meiryo, system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", Consolas, Menlo,
    "Hiragino Kaku Gothic ProN", monospace;
}

/* ---------- Base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  overflow-x: clip;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--ink-950);
  color: var(--plat-200);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.85;
  letter-spacing: 0.02em;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
}

/* Older Safari has no overflow:clip — fall back to hidden so the page
   cannot be panned sideways. */
@supports not (overflow: clip) {
  html,
  body {
    overflow-x: hidden;
  }
}

/* Keep the legacy workbench markup (needed by converter.js) invisible,
   whatever other display rules exist. */
[hidden],
.hidden {
  display: none !important;
}

img {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
  border-radius: 4px;
  box-shadow: 0 0 0 5px rgba(245, 158, 11, 0.22);
}

.cv-skip {
  position: fixed;
  top: -48px;
  left: 16px;
  z-index: 60;
  padding: 10px 18px;
  border-radius: 0 0 10px 10px;
  background: var(--gold);
  color: var(--ink-950);
  font-weight: 700;
  font-size: 0.85rem;
  text-decoration: none;
  transition: top 0.2s var(--ease-out);
}

.cv-skip:focus-visible {
  top: 0;
}

/* ---------- Fixed atmosphere ---------- */
.cv-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(120% 90% at 85% -10%, rgba(15, 42, 68, 0.85) 0%, rgba(15, 42, 68, 0) 55%),
    radial-gradient(90% 70% at -10% 100%, rgba(14, 34, 54, 0.7) 0%, rgba(14, 34, 54, 0) 60%),
    linear-gradient(168deg, var(--ink-900) 0%, var(--ink-950) 58%, #030609 100%);
}

.cv-bg::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(230, 232, 236, 0.07) 1px, transparent 1.4px);
  background-size: 26px 26px;
  -webkit-mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0.25) 45%, rgba(0, 0, 0, 0.7) 100%);
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0.25) 45%, rgba(0, 0, 0, 0.7) 100%);
}

.cv-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(140% 100% at 50% 0%, transparent 55%, rgba(3, 6, 10, 0.75) 100%);
}

/* ---------- Nav ---------- */
.cv-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(4, 8, 15, 0.78);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(230, 232, 236, 0.08);
}

.cv-nav-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 14px var(--pad-x);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.cv-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  color: var(--plat-100);
  text-decoration: none;
  white-space: nowrap;
}

.cv-brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--navy) 0%, var(--ink-800) 100%);
  border: 1px solid rgba(245, 158, 11, 0.55);
  color: var(--gold-bright);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.cv-nav-links {
  display: flex;
  align-items: center;
  gap: clamp(4px, 1.6vw, 18px);
  font-size: 0.86rem;
  font-weight: 600;
}

.cv-nav-links a {
  color: var(--plat-300);
  text-decoration: none;
  padding: 10px 4px;
  white-space: nowrap;
  transition: color 0.2s var(--ease-out);
}

.cv-nav-links a:hover {
  color: var(--gold-bright);
}

@media (max-width: 430px) {
  .cv-brand span:last-child {
    display: none;
  }
}

/* ---------- Layout ---------- */
.cv-main {
  position: relative;
  z-index: 1;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 var(--pad-x) clamp(56px, 9vw, 110px);
}

/* ---------- Hero ---------- */
.cv-hero {
  padding: clamp(48px, 9vw, 96px) 0 clamp(30px, 5vw, 52px);
  max-width: 760px;
}

.cv-kicker {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin: 0 0 18px;
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.34em;
  color: var(--plat-400);
  text-transform: uppercase;
}

@media (max-width: 400px) {
  .cv-kicker {
    letter-spacing: 0.22em;
  }
}

.cv-kicker::before {
  content: "";
  width: 34px;
  height: 1px;
  background: linear-gradient(90deg, var(--gold), rgba(245, 158, 11, 0));
}

.cv-badge {
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid rgba(245, 158, 11, 0.6);
  background: rgba(245, 158, 11, 0.12);
  color: var(--gold-bright);
  font-size: 0.66rem;
  letter-spacing: 0.18em;
}

.cv-hero h1 {
  margin: 0 0 18px;
  font-family: var(--font-display);
  font-size: clamp(1.85rem, 5vw, 3.3rem);
  font-weight: 700;
  line-height: 1.28;
  letter-spacing: 0.01em;
  color: var(--plat-50);
  text-wrap: balance;
}

.cv-goldfoil {
  background: linear-gradient(110deg, #8a5a0a 0%, var(--gold) 28%, var(--gold-pale) 50%, var(--gold) 70%, #8a5a0a 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.cv-lead {
  margin: 0;
  max-width: 38em;
  color: var(--plat-300);
  font-size: clamp(0.96rem, 1.6vw, 1.05rem);
}

/* ---------- Converter panel ---------- */
.cv-panel {
  position: relative;
  border-radius: 22px;
  padding: clamp(22px, 4vw, 40px);
  background:
    linear-gradient(160deg, rgba(15, 42, 68, 0.5) 0%, rgba(10, 24, 40, 0.72) 55%, rgba(6, 13, 22, 0.85) 100%);
  border: 1px solid rgba(245, 158, 11, 0.34);
  box-shadow:
    0 0 0 1px rgba(4, 8, 15, 0.6),
    0 24px 70px rgba(2, 5, 9, 0.6),
    0 0 56px rgba(245, 158, 11, 0.07) inset;
  scroll-margin-top: 90px;
}

.cv-panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 8%;
  right: 8%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(245, 158, 11, 0.85), transparent);
}

.cv-io {
  display: grid;
  gap: 18px;
}

.cv-field {
  display: grid;
  gap: 10px;
  /* Grid items default to min-width:auto — Safari lets the mono
     input/textarea intrinsic width push past the viewport. */
  min-width: 0;
}

.cv-input,
.cv-output {
  max-width: 100%;
}

.cv-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.cv-label {
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  color: var(--plat-400);
  text-transform: uppercase;
}

.cv-input {
  width: 100%;
  padding: 16px 18px;
  border-radius: 14px;
  border: 1px solid rgba(230, 232, 236, 0.16);
  background: rgba(4, 8, 15, 0.65);
  color: var(--plat-100);
  font-family: var(--font-mono);
  font-size: 1.02rem;
  letter-spacing: 0.06em;
  transition: border-color 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out);
}

.cv-input::placeholder {
  color: var(--plat-500);
  letter-spacing: 0.04em;
}

.cv-input:hover {
  border-color: rgba(230, 232, 236, 0.3);
}

.cv-input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.18), 0 0 24px rgba(245, 158, 11, 0.12);
}

.cv-hint {
  margin: 0;
  font-size: 0.8rem;
  color: var(--plat-400);
}

.cv-divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 2px 0;
}

.cv-divider::before,
.cv-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(230, 232, 236, 0.18));
}

.cv-divider::after {
  background: linear-gradient(90deg, rgba(230, 232, 236, 0.18), transparent);
}

.cv-divider span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.3em;
  color: var(--gold-bright);
  text-transform: uppercase;
  white-space: nowrap;
}

.cv-divider span::after {
  content: "↓";
  font-size: 0.9rem;
  letter-spacing: 0;
}

.cv-output {
  width: 100%;
  min-height: 17rem;
  padding: 16px 18px;
  border-radius: 14px;
  border: 1px solid rgba(230, 232, 236, 0.16);
  background: rgba(4, 8, 15, 0.65);
  color: var(--plat-100);
  font-family: var(--font-mono);
  font-size: 0.92rem;
  line-height: 1.75;
  letter-spacing: 0.02em;
  resize: vertical;
  transition: border-color 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out);
}

.cv-output::placeholder {
  color: var(--plat-500);
}

.cv-output:focus {
  outline: none;
  border-color: rgba(62, 162, 239, 0.7);
  box-shadow: 0 0 0 4px rgba(62, 162, 239, 0.14);
}

.cv-copy {
  position: relative;
  overflow: hidden;
  min-width: 8.5em;
  padding: 9px 20px;
  border-radius: 999px;
  border: 1px solid rgba(245, 158, 11, 0.65);
  background: linear-gradient(120deg, #8a5a0a 0%, var(--gold) 35%, var(--gold-pale) 52%, var(--gold) 68%, #8a5a0a 100%);
  background-size: 220% 100%;
  background-position: 18% 0;
  color: #1d1303;
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: background-position 0.55s var(--ease-out), transform 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out);
}

.cv-copy:hover {
  background-position: 82% 0;
  transform: translateY(-1px);
  box-shadow: 0 6px 22px rgba(245, 158, 11, 0.3);
}

.cv-copy:active {
  transform: translateY(0);
}

.cv-message {
  margin: 14px 0 0;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--red-soft);
}

.cv-message:empty {
  display: none;
}

.cv-warnings {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.cv-warnings:empty {
  display: none;
}

.cv-warnings .ptcgl-warning {
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-left: 3px solid var(--gold);
  background: rgba(245, 158, 11, 0.08);
  color: var(--gold-pale);
  font-size: 0.84rem;
  line-height: 1.7;
}

/* ---------- Sections shared ---------- */
.cv-section {
  margin-top: clamp(52px, 8vw, 88px);
}

.cv-section-head {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-bottom: clamp(20px, 3.5vw, 32px);
}

.cv-section-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.3rem, 2.8vw, 1.8rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--plat-50);
}

.cv-section-num {
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.26em;
  color: var(--gold);
}

/* ---------- Flow steps ---------- */
.cv-flow {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(14px, 2.5vw, 22px);
  counter-reset: cvstep;
}

.cv-step {
  position: relative;
  padding: clamp(20px, 3vw, 28px);
  border-radius: 18px;
  background: linear-gradient(165deg, rgba(15, 42, 68, 0.34) 0%, rgba(6, 13, 22, 0.6) 100%);
  border: 1px solid rgba(230, 232, 236, 0.1);
  counter-increment: cvstep;
}

.cv-step::before {
  content: "0" counter(cvstep);
  display: block;
  margin-bottom: 12px;
  font-family: var(--font-display);
  font-size: 1.9rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.04em;
  background: linear-gradient(180deg, var(--plat-100) 0%, var(--plat-400) 70%, var(--plat-500) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.cv-step h3 {
  margin: 0 0 8px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--plat-100);
}

.cv-step p {
  margin: 0;
  font-size: 0.88rem;
  color: var(--plat-400);
}

.cv-step p a {
  color: var(--blue-bright);
  text-decoration: underline;
  text-underline-offset: 3px;
}

@media (max-width: 760px) {
  .cv-flow {
    grid-template-columns: 1fr;
  }
}

/* ---------- Notes ---------- */
.cv-notes {
  border-radius: 18px;
  padding: clamp(22px, 3.5vw, 32px);
  background: rgba(6, 13, 22, 0.55);
  border: 1px solid rgba(230, 232, 236, 0.1);
}

.cv-notes ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 12px;
}

.cv-notes li {
  position: relative;
  padding-left: 22px;
  font-size: 0.9rem;
  color: var(--plat-300);
}

.cv-notes li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 0.72em;
  width: 8px;
  height: 1.5px;
  background: var(--gold);
}

.cv-notes strong {
  color: var(--plat-100);
  font-weight: 700;
}

/* ---------- Cross tools ---------- */
.cv-tools {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: clamp(14px, 2.5vw, 22px);
}

.cv-tool {
  --accent: var(--blue-bright);
  display: block;
  padding: clamp(20px, 3vw, 28px);
  border-radius: 18px;
  background: linear-gradient(165deg, rgba(15, 42, 68, 0.34) 0%, rgba(6, 13, 22, 0.6) 100%);
  border: 1px solid rgba(230, 232, 236, 0.1);
  text-decoration: none;
  transition: transform 0.25s var(--ease-out), border-color 0.25s var(--ease-out), box-shadow 0.25s var(--ease-out);
}

.cv-tool:hover {
  transform: translateY(-3px);
  border-color: rgba(62, 162, 239, 0.55);
  box-shadow: 0 14px 40px rgba(2, 5, 9, 0.55);
}

.cv-tool--steel {
  --accent: #7da7c7;
}

.cv-tool--steel:hover {
  border-color: rgba(125, 167, 199, 0.55);
}

.cv-tool-kicker {
  display: block;
  margin-bottom: 10px;
  font-family: var(--font-display);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.28em;
  color: var(--accent);
  text-transform: uppercase;
}

.cv-tool h3 {
  margin: 0 0 8px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--plat-100);
}

.cv-tool p {
  margin: 0;
  font-size: 0.86rem;
  color: var(--plat-400);
}

.cv-tool-cta {
  display: inline-block;
  margin-top: 14px;
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--plat-200);
}

.cv-tool-cta::after {
  content: " →";
  color: var(--accent);
}

@media (max-width: 700px) {
  .cv-tools {
    grid-template-columns: 1fr;
  }
}

/* ---------- Footer ---------- */
.cv-footer {
  position: relative;
  z-index: 1;
  border-top: 1px solid rgba(230, 232, 236, 0.09);
  background: rgba(3, 6, 10, 0.82);
}

.cv-footer-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(28px, 5vw, 44px) var(--pad-x);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.cv-footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  font-size: 0.84rem;
}

.cv-footer-nav a {
  color: var(--plat-400);
  text-decoration: none;
}

.cv-footer-nav a:hover {
  color: var(--gold-bright);
}

.cv-footer-legal {
  width: 100%;
  margin: 4px 0 0;
  font-size: 0.74rem;
  line-height: 1.8;
  color: var(--plat-400);
}

/* ---------- h1 sub-line ---------- */
.cv-h1-sub {
  display: block;
  margin-top: 0.5em;
  font-size: 0.5em;
  font-weight: 600;
  line-height: 1.5;
  color: var(--plat-300);
  letter-spacing: 0.01em;
}

/* ---------- FAQ ---------- */
.cv-faq {
  display: grid;
  gap: 0;
  border-radius: 18px;
  padding: clamp(20px, 3.4vw, 30px);
  background: rgba(6, 13, 22, 0.55);
  border: 1px solid rgba(230, 232, 236, 0.1);
}

.cv-faq dt {
  margin-top: 18px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--plat-100);
}

.cv-faq dt::before {
  content: "Q. ";
  color: var(--gold-bright);
}

.cv-faq dt:first-of-type {
  margin-top: 0;
}

.cv-faq dd {
  margin: 6px 0 0;
  padding: 0 0 16px;
  font-size: 0.88rem;
  color: var(--plat-300);
  border-bottom: 1px solid rgba(230, 232, 236, 0.07);
}

.cv-faq dd:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

/* ---------- Lab Instrument signature ---------- */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 80;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.72' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.05'/%3E%3C/svg%3E");
  background-size: 180px 180px;
  opacity: 0.55;
}

.cv-notes,
.cv-faq {
  position: relative;
}

.cv-step::after,
.cv-notes::before,
.cv-faq::after {
  content: "";
  position: absolute;
  inset: 9px;
  pointer-events: none;
  background:
    linear-gradient(rgba(245, 158, 11, 0.55), rgba(245, 158, 11, 0.55)) left top / 14px 1.5px,
    linear-gradient(rgba(245, 158, 11, 0.55), rgba(245, 158, 11, 0.55)) left top / 1.5px 14px,
    linear-gradient(rgba(230, 232, 236, 0.28), rgba(230, 232, 236, 0.28)) right bottom / 14px 1.5px,
    linear-gradient(rgba(230, 232, 236, 0.28), rgba(230, 232, 236, 0.28)) right bottom / 1.5px 14px;
  background-repeat: no-repeat;
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
