/* card.css - LOCKED parchment card art (frame, circle, stats strip, 63x88mm print size) + preview area, card action dock, card flip, range slider. Card visuals must NOT change. Part of the split-up style.css; see index.html for load order. */
  /* ── RIGHT PANEL ── */
  .preview-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 2.5rem 2rem;
    gap: 1.5rem;
    overflow-y: auto;
    background: rgba(10,5,2,0.5);
    position: relative;
  }

  /* (scrollbars unified globally near the top of this file) */

  /* ── ITEM CARD ── */
  .item-card {
    width: var(--card-w);
    min-height: var(--card-h);
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 8px 60px rgba(0,0,0,0.7), 0 0 0 1px rgba(180,130,60,0.3);
    flex-shrink: 0;
  }

  /* Background layer — solid colour only */
  .card-bg {
    position: absolute;
    inset: 0;
    background: #d4b87a;
    z-index: 0;
  }

  /* Background image layer — separate so opacity can be controlled independently */
  .card-bg-img {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    z-index: 0;
  }

  /* Parchment texture overlay — real div so html2canvas captures it */
  .card-texture {
    position: absolute;
    inset: 0;
    background:
      repeating-linear-gradient(45deg, transparent, transparent 2px, rgba(0,0,0,0.015) 2px, rgba(0,0,0,0.015) 4px);
    z-index: 0;
    pointer-events: none;
  }

  /* Vignette */
  .card-vignette {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, transparent 40%, rgba(0,0,0,0.45) 100%);
    z-index: 1;
    pointer-events: none;
  }

  .card-content {
    position: relative;
    z-index: 2;
    padding: 0;
    display: flex;
    flex-direction: column;
    height: 531px;
    overflow: hidden;
  }

  /* Ornate border frame */
  .card-frame {
    position: absolute;
    inset: 8px;
    border: 1.5px solid rgba(100,70,30,0.5);
    border-radius: 5px;
    pointer-events: none;
    z-index: 10;
  }

  /* Inner frame line — real div */
  .card-frame-inner {
    position: absolute;
    inset: 3px;
    border: 0.5px solid rgba(100,70,30,0.25);
    border-radius: 3px;
    pointer-events: none;
  }

  /* Top ornament — CSS diamond, no font/transform dependency for centering */
  .card-frame-ornament {
    position: absolute;
    top: -5px;
    left: 50%;
    margin-left: -5px;
    width: 10px;
    height: 10px;
    transform: rotate(45deg);
    background: rgba(100,70,30,0.5);
    pointer-events: none;
  }

  /* Header band */
  .card-header {
    padding: 18px 20px 10px;
    text-align: center;
    position: relative;
  }

  .card-item-name {
    font-family: 'Cinzel', serif;
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--ink);
    text-shadow: 0 1px 0 rgba(255,255,255,0.3);
    letter-spacing: 0.04em;
  }

  .card-subtype {
    font-family: 'Cinzel', serif;
    font-size: 0.65rem;
    color: var(--ink-light);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin-top: 3px;
    opacity: 0.85;
    white-space: nowrap;
    overflow: hidden;
  }

  /* Divider */
  .card-divider {
    height: 1px;
    margin: 0 16px;
    background: linear-gradient(to right, transparent, rgba(90,60,30,0.5) 20%, rgba(90,60,30,0.5) 80%, transparent);
    position: relative;
  }

  /* CSS diamond centred on the 1px divider line — no font/character dependency */
  .divider-gem {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 7px;
    height: 7px;
    margin-left: -3.5px;
    margin-top: -3.5px;
    transform: rotate(45deg);
    background: rgba(90,60,30,0.55);
    pointer-events: none;
    font-size: 0;
  }

  /* Item image area */
  .card-image-wrap {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    align-items: center;
    padding: 8px 20px 4px;
    min-height: 120px;
  }

  .card-side-stat {
    text-align: center;
    padding: 0 6px;
  }

  .side-stat-label {
    font-family: 'Cinzel', serif;
    font-size: 0.52rem;
    letter-spacing: 0.12em;
    color: var(--ink-light);
    opacity: 0.8;
    text-transform: uppercase;
    display: block;
  }

  .side-stat-value {
    font-family: 'Cinzel', serif;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--ink);
    display: block;
    margin-top: 3px;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
  }

  .card-image-container {
    width: 110px;
    height: 110px;
    border-radius: 50%;
    border: 2px solid rgba(90,60,30,0.45);
    overflow: hidden;
    background: rgba(90,60,30,0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    grid-column: 2;
    justify-self: center;
  }

  .card-image-container img {
    position: absolute;
    cursor: grab;
    user-select: none;
    -webkit-user-drag: none;
  }
  .card-image-container img:active { cursor: grabbing; }

  .img-drag-hint {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    background: rgba(0,0,0,0.52);
    color: rgba(255,255,255,0.92);
    opacity: 0;
    transition: opacity 0.18s;
    pointer-events: none;
    z-index: 5;
    text-align: center;
  }
  .img-drag-hint .hint-icon {
    font-size: 1.1rem;
    line-height: 1;
  }
  .img-drag-hint .hint-text {
    font-family: 'Cinzel', serif;
    font-size: 0.58rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    line-height: 1.5;
  }
  .card-image-container.has-img:hover .img-drag-hint { opacity: 1; }

  .card-image-placeholder {
    color: rgba(90,60,30,0.4);
    font-size: 2.5rem;
    user-select: none;
  }

  /* Stats strip */
  .card-stats {
    display: flex;
    justify-content: center;
    gap: 0;
    padding: 4px 20px;
  }

  .card-stat {
    text-align: center;
    padding: 3px 12px;
    border-right: 1px solid rgba(90,60,30,0.3);
    flex: 1;
  }

  .card-stat:last-child { border-right: none; }

  .stat-label {
    font-family: 'Cinzel', serif;
    font-size: 0.52rem;
    letter-spacing: 0.12em;
    color: var(--ink-light);
    opacity: 0.8;
    text-transform: uppercase;
    display: block;
  }

  .card-stat {
    min-width: 0; /* allow flex item to shrink so stat-value overflow is measurable */
  }

  .stat-value {
    font-family: 'Cinzel', serif;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--ink);
    display: block;
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
  }

  /* Rarity badge on card */
  .card-rarity {
    display: block;
    text-align: center;
    font-family: 'Cinzel', serif;
    font-size: 0.6rem;
    line-height: 1;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    padding: 2px 0;
  }

  /* Description body */
  .card-body {
    padding: 8px 20px 16px;
    flex: 1;
    overflow: hidden;
    min-height: 0;
  }

  .card-description {
    font-family: 'Crimson Pro', Georgia, serif;
    font-size: 0.87rem;
    line-height: 1.5;
    color: var(--ink);
    overflow-wrap: break-word;
    word-break: break-word;
  }

  /* Markdown styles inside card */
  .card-description p { margin-bottom: 0.5em; }
  .card-description p:last-child { margin-bottom: 0; }
  .card-description strong { font-weight: 600; color: var(--ink); }
  .card-description em { font-style: italic; }
  .card-description ul { padding-left: 1.2em; margin: 0.3em 0; }
  .card-description li { margin-bottom: 0.2em; }
  .card-description h1,
  .card-description h2,
  .card-description h3 {
    font-family: 'Cinzel', serif;
    font-weight: 600;
    color: var(--ink);
    margin: 0.5em 0 0.3em;
    font-size: 0.88rem;
  }
  .card-description hr {
    border: none;
    border-top: 1px solid rgba(90,60,30,0.3);
    margin: 0.5em 0;
  }
  .card-description blockquote {
    border-left: 2px solid rgba(90,60,30,0.4);
    padding-left: 0.7em;
    font-style: italic;
    color: var(--ink-light);
    margin: 0.4em 0;
  }

  /* Attunement tag */
  .card-attunement {
    margin: 0 16px 4px;
    text-align: center;
    font-family: 'Crimson Pro', serif;
    font-style: italic;
    font-size: 0.75rem;
    color: var(--ink-light);
    opacity: 0.85;
    padding-top: 4px;
    border-top: 1px solid rgba(90,60,30,0.2);
  }

  /* Footer of card */
  .card-footer {
    padding: 8px 18px 14px;
    text-align: center;
  }

  .card-source {
    font-family: 'Cinzel', serif;
    font-size: 0.55rem;
    letter-spacing: 0.1em;
    color: rgba(44,26,14,0.45);
    text-transform: uppercase;
  }

  /* Rarity colors */
  .rarity-common      { color: #555; border-color: #aaa; }
  .rarity-uncommon    { color: #1a6e1a; border-color: #3a9a3a; }
  .rarity-rare        { color: #1a3e8b; border-color: #3a6acc; }
  .rarity-very-rare   { color: #5a1a8b; border-color: #8a3acc; }
  .rarity-legendary   { color: #8b4a00; border-color: #c97d00; }
  .rarity-artifact    { color: #8b1a1a; border-color: #cc3a3a; }
  .rarity-unique      { color: #2e6b6b; border-color: #4a9a9a; }

  /* Rarity colors on the dark history bar — use the lighter border-color values */
  .history-rarity.rarity-common      { color: #aaa; }
  .history-rarity.rarity-uncommon    { color: #3a9a3a; }
  .history-rarity.rarity-rare        { color: #3a6acc; }
  .history-rarity.rarity-very-rare   { color: #8a3acc; }
  .history-rarity.rarity-legendary   { color: #c97d00; }
  .history-rarity.rarity-artifact    { color: #cc3a3a; }
  .history-rarity.rarity-unique      { color: #4a9a9a; }

  /* Export hint */
  .export-hint {
    font-size: small;
    color: #a07840;
    text-align: center;
    letter-spacing: 0.03em;
  }

  /* ── CARD ACTION DOCK (under the preview) ── */
  .card-action-dock {
    display: flex;
    align-items: stretch;
    gap: 0.5rem;
    width: 100%;
    max-width: 460px;
    margin: 0.4rem auto 0;
    flex-shrink: 0;
  }
  .dock-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    height: 40px;
    padding: 0 0.7rem;
    border: 1px solid rgba(216,178,102,0.4);
    border-radius: var(--arc-r-control);
    background: var(--arc-ink-soft);
    color: var(--arc-gold);
    font-family: var(--arc-display);
    font-size: 0.66rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: filter 0.15s, background 0.15s, border-color 0.15s;
  }
  .dock-btn:hover { background: var(--arc-ink-raised); border-color: var(--arc-gold); color: var(--arc-gold-hi); }
  .dock-btn .dock-ic { font-size: 0.85rem; }
  .dock-btn-primary {
    flex: 1;
    border: none;
    background: linear-gradient(180deg, var(--arc-gold), var(--arc-gold-mid));
    color: var(--arc-ink);
    box-shadow: var(--arc-inset-gold);
  }
  .dock-btn-primary:hover { filter: brightness(1.08); background: linear-gradient(180deg, var(--arc-gold), var(--arc-gold-mid)); color: var(--arc-ink); }

  /* Scale control */
  .scale-control {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    font-size: small;
    color: var(--label-color);
  }

  .scale-control input[type="range"] {
    width: 100px;
  }

  /* ── Card flip (scaleX fold — avoids GPU compositing layer that blurs child images) ── */
  .card-flip-container {
    position: relative;
    transition: transform 0.18s ease-in;
  }
  .card-flip-container.folding {
    transform: scaleX(0);
  }
  .card-flip-back {
    position: absolute;
    inset: 0;
    width: var(--card-w);
    height: var(--card-h);
    border-radius: 8px;
    overflow: hidden;
    display: none;
    pointer-events: none;
  }
  .card-flip-back.visible {
    display: block;
  }
  .card-flip-back img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    user-select: none;
  }

  /* Scale reset + flip buttons */
  .scale-reset-btn {
    font-size: small;
    padding: 0.15rem 0.35rem;
    border-radius: 4px;
    border: 1px solid transparent;
    background: transparent;
    color: rgba(180,130,60,0.5);
    cursor: pointer;
    flex-shrink: 0;
    transition: color 0.15s, border-color 0.15s;
  }
  .scale-reset-btn:hover {
    color: var(--gold-light);
    border-color: rgba(180,130,60,0.3);
  }
  .scale-flip-btn {
    font-size: small;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    border: 1px solid rgba(180,130,60,0.3);
    background: transparent;
    color: #c9a96e;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
  }
  .scale-flip-btn:hover {
    border-color: rgba(180,130,60,0.6);
    color: var(--gold-light);
  }
  .scale-flip-btn[aria-pressed="true"] {
    background: rgba(180,130,60,0.15);
    border-color: rgba(180,130,60,0.5);
    color: var(--gold-light);
  }

  /* ── Range slider theme ── */
  input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    border-radius: 2px;
    background: rgba(180,130,60,0.25);
    outline: none;
    cursor: pointer;
  }
  input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--gold);
    border: 2px solid var(--gold-light);
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
  }
  input[type="range"]::-webkit-slider-thumb:hover {
    background: var(--gold-light);
    transform: scale(1.15);
  }
  input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--gold);
    border: 2px solid var(--gold-light);
    cursor: pointer;
  }
  input[type="range"]::-moz-range-track {
    height: 4px;
    border-radius: 2px;
    background: rgba(180,130,60,0.25);
  }

  body.light input[type="range"] {
    background: rgba(120,80,30,0.2);
  }
  body.light input[type="range"]::-webkit-slider-thumb {
    background: #8a5c18;
    border-color: #b07830;
  }
  body.light input[type="range"]::-webkit-slider-thumb:hover {
    background: #b07830;
  }
  body.light input[type="range"]::-moz-range-thumb {
    background: #8a5c18;
    border-color: #b07830;
  }
  body.light input[type="range"]::-moz-range-track {
    background: rgba(120,80,30,0.2);
  }

  /* Markdown helper */
  .md-hint {
    font-size: small;
    color: #6a4e2e;
    padding: 0.4rem 0.6rem;
    background: rgba(180,130,60,0.06);
    border-radius: 3px;
    border: 1px solid rgba(180,130,60,0.12);
    line-height: 1.5;
  }

  .md-hint code {
    font-family: monospace;
    background: rgba(180,130,60,0.12);
    padding: 0 3px;
    border-radius: 2px;
    font-size: 0.85em;
    color: #a0804a;
  }

  /* Checkbox toggle */
  .toggle-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: medium;
    color: var(--label-color);
    cursor: pointer;
  }

  .toggle-wrap {
    position: relative;
    display: inline-block;
    width: 34px;
    height: 18px;
    flex-shrink: 0;
  }
  .toggle-wrap input[type="checkbox"] {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
  }
  .toggle-knob {
    position: absolute;
    inset: 0;
    background: rgba(180,130,60,0.15);
    border: 1px solid rgba(180,130,60,0.3);
    border-radius: 9px;
    transition: background 0.2s, border-color 0.2s;
    cursor: pointer;
  }
  .toggle-knob::before {
    content: '';
    position: absolute;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgba(180,130,60,0.5);
    top: 2px;
    left: 2px;
    transition: transform 0.2s, background 0.2s;
  }
  .toggle-wrap input:checked + .toggle-knob {
    background: rgba(180,130,60,0.35);
    border-color: rgba(180,130,60,0.7);
  }
  .toggle-wrap input:checked + .toggle-knob::before {
    transform: translateX(16px);
    background: var(--gold-light);
  }

