/* =============================================================
   AI Transparency Scale — Stylesheet
   Requires: Inter font (loaded via Google Fonts in HTML)
   Breakpoint: ≥ 800px = desktop, < 800px = mobile
   ============================================================= */


/* ── Design tokens ── */

:root {
  --bg:     #f4f3ef;
  --bg2:    #e8e7e1;
  --text:   #0e0e0c;   /* 17.8:1 on --bg ✓ WCAG AAA */
  --muted:  #4a4a45;   /* 7.1:1  on --bg ✓ WCAG AA  */
  --subtle: #6b6b66;   /* 4.8:1  on --bg ✓ WCAG AA  */
  --line:   rgba(0, 0, 0, 0.11);
  --ink:    #0e0e0c;
  --font:   'Inter', system-ui, sans-serif;
  --hh:     52px;   /* header height */
  --fh:     40px;   /* footer height */
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:     #0f0f0d;
    --bg2:    #1a1a18;
    --text:   #f2f0eb;   /* 17.5:1 on --bg ✓ WCAG AAA */
    --muted:  #b8b8b0;   /* 6.9:1  on --bg ✓ WCAG AA  */
    --subtle: #7a7a72;   /* 4.6:1  on --bg ✓ WCAG AA  */
    --line:   rgba(255, 255, 255, 0.09);
    --ink:    #f2f0eb;
  }
}


/* ── Reset ── */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin:     0;
  padding:    0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font);
  background:  var(--bg);
  color:       var(--text);
}


/* ── Header ── */

header {
  height:          var(--hh);
  display:         flex;
  align-items:     center;
  justify-content: space-between;
  padding:         0 1.5rem;
  border-bottom:   1px solid var(--line);
  position:        sticky;
  top:             0;
  z-index:         10;
  background:      var(--bg);
}

.wordmark {
  font-size:      10px;
  font-weight:    700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color:          var(--muted);
}

.hbtns { display: flex; gap: 6px; }

.hbtn {
  font-family:    var(--font);
  font-size:      11px;
  font-weight:    600;
  padding:        5px 14px;
  border-radius:  20px;
  cursor:         pointer;
  border:         1px solid var(--line);
  background:     transparent;
  color:          var(--text);
  transition:     opacity .15s;
  white-space:    nowrap;
}
.hbtn.filled {
  background:   var(--ink);
  color:        var(--bg);
  border-color: transparent;
}
.hbtn:hover { opacity: .7; }


/* ── Footer ── */

footer {
  border-top:      1px solid var(--line);
  height:          var(--fh);
  display:         flex;
  align-items:     center;
  justify-content: center;
  font-size:       10.5px;
  color:           var(--subtle);
  letter-spacing:  .02em;
  text-align:      center;
  padding:         0 1rem;
}


/* =============================================================
   DESKTOP layout  (≥ 800px)
   - body fills viewport; no page scroll
   - .app is a 2-column grid: panel | right
   - each column scrolls independently
   ============================================================= */

@media (min-width: 800px) {

  body {
    height:         100dvh;
    overflow:       hidden;
    display:        flex;
    flex-direction: column;
  }

  /* 2-column grid */
  .app {
    flex:                   1;
    min-height:             0;
    display:                grid;
    grid-template-columns:  272px 1fr;
    grid-template-rows:     1fr;
  }

  /* Mobile canvas is not needed on desktop */
  .mobile-canvas-wrap { display: none !important; }

  /* Left column — settings panel */
  .panel {
    grid-column:    1;
    grid-row:       1;
    border-right:   1px solid var(--line);
    padding:        1.5rem;
    overflow-y:     auto;
    display:        flex;
    flex-direction: column;
    gap:            1.5rem;
  }

  /* Right column — canvas + description cards */
  .right {
    grid-column:    2;
    grid-row:       1;
    display:        flex;
    flex-direction: column;
    align-items:    center;
    padding:        1.5rem;
    gap:            1rem;
    overflow-y:     auto;
    min-height:     0;
  }

  /* Canvas frame — width & height set by JS to maintain aspect ratio */
  .canvas-frame {
    position:      relative;
    border-radius: 12px;
    overflow:      hidden;
    background:    var(--bg2);
    border:        1px solid var(--line);
    touch-action:  none;
    flex-shrink:   0;
    align-self:    center;
  }
  .canvas-frame canvas {
    position: absolute;
    top:      0;
    left:     0;
    width:    100%;
    height:   100%;
    display:  block;
  }

  /* Hide mobile-only elements */
  .mobile-canvas-frame,
  .hint-mobile { display: none; }
}


/* =============================================================
   MOBILE layout  (< 800px)
   - normal page scroll
   - mobile canvas is sticky below the header (~50svh)
   - settings panel and desc cards scroll below it
   ============================================================= */

@media (max-width: 799px) {

  body       { display: block; overflow-y: auto; }
  .app       { display: flex; flex-direction: column; }

  /* Sticky canvas block */
  .mobile-canvas-wrap {
    position:        sticky;
    top:             var(--hh);
    z-index:         5;
    height:          calc(50svh - var(--hh) / 2);
    background:      var(--bg2);
    border-bottom:   1px solid var(--line);
    display:         flex;
    align-items:     center;
    justify-content: center;
    padding:         .75rem;
  }

  .mobile-canvas-inner {
    display:        flex;
    flex-direction: column;
    align-items:    center;
    width:          100%;
    height:         100%;
  }

  /* Canvas frame — width & height set by JS */
  .mobile-canvas-frame {
    position:      relative;
    border-radius: 10px;
    overflow:      hidden;
    background:    var(--bg2);
    touch-action:  none;
  }
  .mobile-canvas-frame canvas {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    display: block;
  }

  .hint-mobile {
    font-size:      9.5px;
    color:          var(--subtle);
    text-align:     center;
    padding:        .35rem 0 0;
    letter-spacing: .03em;
  }

  /* Settings panel */
  .panel {
    padding:        1.25rem 1rem;
    display:        flex;
    flex-direction: column;
    gap:            1.35rem;
  }

  /* Right col: canvas hint only on mobile (no desc cards — they're inline) */
  .right {
    padding:        .75rem 1rem .5rem;
    display:        flex;
    flex-direction: column;
    gap:            .5rem;
  }

  /* Hide desktop-only elements */
  .canvas-frame,
  .hint { display: none; }
}


/* =============================================================
   Shared component styles
   ============================================================= */


/* Section label */
.plabel {
  font-size:      10px;
  font-weight:    700;
  letter-spacing: .10em;
  text-transform: uppercase;
  color:          var(--subtle);
  margin-bottom:  .7rem;
}

/* Spacing helper */
.gap { height: 6px; }

/* Hint text below desktop canvas */
.hint {
  font-size:      10px;
  color:          var(--subtle);
  text-align:     center;
  letter-spacing: .04em;
  width:          100%;
}


/* ── Color toggle ── */

.toggle-strip {
  display:       flex;
  gap:           3px;
  background:    var(--bg2);
  border-radius: 8px;
  padding:       3px;
}
.toggle-strip button {
  flex:           1;
  padding:        7px 0;
  border:         none;
  border-radius:  6px;
  cursor:         pointer;
  font-family:    var(--font);
  font-size:      12px;
  font-weight:    600;
  background:     transparent;
  color:          var(--muted);
  transition:     background .15s, color .15s;
}
.toggle-strip button.active {
  background: var(--ink);
  color:      var(--bg);
}


/* ── Adjustment sliders ── */

.adj-list { display: flex; flex-direction: column; gap: 1.35rem; }

.adj-item { /* wrapper div for each segment row */ }

.adj-top {
  display:         flex;
  align-items:     baseline;
  justify-content: space-between;
  margin-bottom:   2px;
}
.adj-name {
  font-size:   13px;
  font-weight: 700;
  color:       var(--text);
}
.adj-val {
  font-size:      22px;
  font-weight:    300;
  color:          var(--text);
  letter-spacing: -.03em;
  line-height:    1;
}
.adj-desc {
  font-size:     11.5px;
  line-height:   1.55;
  color:         var(--muted);
  margin-bottom: 8px;
}

/*
  Range input — centred thumb
  The input element is given height = thumb height (22px).
  WebKit needs an explicit margin-top on the thumb to compensate
  for the difference between the track height (4px) and the
  thumb height (22px): margin-top = -(thumbH/2 - trackH/2) = -9px.
  Firefox centres the thumb automatically when using appearance:none.
*/
input[type="range"] {
  -webkit-appearance: none;
  appearance:         none;
  display:            block;
  width:              100%;
  height:             22px;   /* matches thumb height */
  background:         transparent;
  outline:            none;
  cursor:             pointer;
  padding:            0;
  margin:             0;
}
input[type="range"]::-webkit-slider-runnable-track {
  height:        4px;
  border-radius: 2px;
  background:    var(--line);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width:              22px;
  height:             22px;
  border-radius:      50%;
  background:         var(--ink);
  border:             3px solid var(--bg);
  box-shadow:         0 0 0 1.5px var(--ink);
  cursor:             pointer;
  margin-top:         -9px;   /* (4px/2) - (22px/2) = -9px */
}
input[type="range"]::-moz-range-track {
  height:        4px;
  border-radius: 2px;
  background:    var(--line);
}
input[type="range"]::-moz-range-thumb {
  width:         22px;
  height:        22px;
  border-radius: 50%;
  background:    var(--ink);
  border:        3px solid var(--bg);
  box-shadow:    0 0 0 1.5px var(--ink);
  cursor:        pointer;
}


/* ── Upload zone ── */

.upload-zone {
  display:        block;
  border:         1.5px dashed var(--line);
  border-radius:  8px;
  padding:        12px;
  text-align:     center;
  cursor:         pointer;
  color:          var(--muted);
  font-size:      12px;
  font-weight:    500;
  transition:     border-color .15s, background .15s;
}
.upload-zone:hover {
  border-color: var(--subtle);
  background:   var(--bg2);
}


/* ── Ghost button ── */

.ghost-btn {
  display:       block;
  width:         100%;
  font-family:   var(--font);
  font-size:     12px;
  font-weight:   600;
  color:         var(--muted);
  background:    none;
  border:        1px solid var(--line);
  border-radius: 7px;
  padding:       8px 0;
  cursor:        pointer;
  transition:    color .15s, border-color .15s;
}
.ghost-btn:hover {
  color:        var(--text);
  border-color: var(--subtle);
}


/* ── Description cards ── */

.desc-card {
  border:        1px solid var(--line);
  border-radius: 10px;
  padding:       .9rem .95rem;
  background:    var(--bg2);
}

/* Inline desc card — fixed height so nothing jumps when text changes */
.inline-desc {
  margin-top:    .65rem;
  border-left:   2px solid var(--line);
  border-top:    none;
  border-right:  none;
  border-bottom: none;
  border-radius: 0;
  padding:       .55rem .9rem;
  background:    transparent;
  /* Height locked: head (1 line) + body (3 lines) + gap + label */
  height:        88px;
  overflow:      hidden;
}

.dc-label {
  font-size:      9px;
  font-weight:    700;
  letter-spacing: .10em;
  text-transform: uppercase;
  color:          var(--subtle);
  margin-bottom:  .25rem;
}
.dc-head {
  font-size:     14px;
  font-weight:   700;
  line-height:   1.2;
  color:         var(--text);
  margin-bottom: .2rem;
  transition:    opacity .18s ease;
  white-space:   nowrap;
  overflow:      hidden;
  text-overflow: ellipsis;
}
.dc-body {
  font-size:          11.5px;
  line-height:        1.5;
  color:              var(--muted);
  transition:         opacity .18s ease;
  display:            -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow:           hidden;
}
