/* ==========================================================================
   IpSVM QRgen — Design System & Stylesheet
   Consistent with ipsvm.eu and enol.ipsvm.eu design language.
   ========================================================================== */

/* ------------------------------------------------------------------ Fonts */
@font-face {
  font-family: 'Instrument Serif';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('assets/fonts/instrument-serif-latin-ext-400-normal.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: 'Instrument Serif';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('assets/fonts/instrument-serif-latin-400-normal.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;
}

@font-face {
  font-family: 'Instrument Serif';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('assets/fonts/instrument-serif-latin-ext-400-italic.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: 'Instrument Serif';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('assets/fonts/instrument-serif-latin-400-italic.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;
}

@font-face {
  font-family: 'Geist';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('assets/fonts/geist-latin-ext-wght-normal.woff2') format('woff2-variations');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: 'Geist';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('assets/fonts/geist-latin-wght-normal.woff2') format('woff2-variations');
  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 {
  /* Warm, paper-like beige from IpSVM / ENOL ecosystem */
  --site-ground: #eae6db;
  --site-raised: #f4efe3;
  --site-well: #e3ded2;
  --site-rule: #c9c4b6;
  --site-rule-subtle: #dcd7ca;
  --site-text: #15181e;     /* Iron gall blue-black */
  --site-quiet: #5a554c;
  --site-faint: #8a8274;
  --site-bronze: #7d4f24;

  /* IpSVM porphyry burgundy accent for primary action buttons */
  --site-porphyry: #6e2c35;
  --site-porphyry-hover: #5b232b;

  --font-serif: 'Instrument Serif', 'Iowan Old Style', Georgia, serif;
  --font-sans: 'Geist', system-ui, -apple-system, sans-serif;

  --ease-settle: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ------------------------------------------------------------------ Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  background-color: var(--site-ground);
  color: var(--site-text);
  font-family: var(--font-sans);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background-color: var(--site-ground);
  color: var(--site-text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

::selection {
  background-color: var(--site-bronze);
  color: var(--site-raised);
}

:focus-visible {
  outline: 2px solid var(--site-bronze);
  outline-offset: 3px;
}

/* ------------------------------------------------------------------ Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  width: 100%;
  background-color: var(--site-ground);
  border-bottom: 1px solid var(--site-rule);
  color: var(--site-text);
}

.header-inner {
  max-width: 62rem;
  margin: 0 auto;
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.logo-link {
  display: flex;
  align-items: center;
  text-decoration: none;
  transition: opacity 160ms var(--ease-settle);
}

.logo-link:hover {
  opacity: 0.75;
}

.header-wordmark {
  height: 1.35rem; /* ~22px height */
  width: auto;
  display: block;
}

.header-sep {
  color: var(--site-rule);
  font-size: 1rem;
  font-weight: 300;
  user-select: none;
}

.header-title {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 400;
  color: var(--site-text);
  letter-spacing: -0.01em;
  user-select: none;
  line-height: 1;
}

.header-meta {
  display: flex;
  align-items: center;
}

.header-link {
  color: var(--site-quiet);
  text-decoration: none;
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: none;
  transition: color 150ms var(--ease-settle);
}

button.header-link {
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  line-height: inherit;
  cursor: pointer;
}

.header-link:hover {
  color: var(--site-text);
}

button.header-link:focus-visible {
  outline: 2px solid var(--accent-burgundy);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

/* ------------------------------------------------------------------ Main Layout */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 2rem 1.5rem;
}

.content-container {
  width: 100%;
  max-width: 62rem;
  margin: auto auto;
}

.page-heading-block {
  margin-bottom: 0.25rem;
}

.page-title {
  font-family: var(--font-serif);
  font-size: clamp(2.2rem, 1.8rem + 1.5vw, 3.2rem);
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--site-text);
}

.generator-grid {
  width: 100%;
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 2.5rem;
  align-items: start;
}

/* ------------------------------------------------------------------ Left Controls */
.controls-column {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.control-label {
  font-size: 0.6875rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--site-quiet);
}

.input-wrapper {
  width: 100%;
}

.text-input {
  width: 100%;
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  line-height: 1.45;
  color: var(--site-text);
  background-color: var(--site-raised);
  border: 1px solid var(--site-rule);
  border-radius: 6px;
  padding: 0.65rem 0.75rem;
  resize: vertical;
  min-height: 4.5rem;
  max-height: 12rem;
  transition: border-color 150ms var(--ease-settle);
}

.text-input:focus {
  outline: none;
  border-color: var(--site-bronze);
  box-shadow: 0 0 0 1px var(--site-bronze);
}

/* Swatches */
.swatches-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.swatch-btn {
  width: 2rem;
  height: 2rem;
  padding: 2px;
  background: transparent;
  border: 1px solid var(--site-rule);
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color 150ms var(--ease-settle), transform 150ms var(--ease-settle);
}

.swatch-btn:hover {
  border-color: var(--site-text);
}

.swatch-btn.is-active {
  border: 2px solid var(--site-porphyry);
  box-shadow: 0 0 0 1px var(--site-ground), 0 0 0 2px var(--site-porphyry);
}

.swatch-plate {
  width: 100%;
  height: 100%;
  border-radius: 3px;
  display: block;
}

/* Swatch Color Definitions */
.swatch-bow {
  /* Black on White */
  background: linear-gradient(135deg, #000000 50%, #ffffff 50%);
}

.swatch-wob {
  /* White on Black */
  background: linear-gradient(135deg, #ffffff 50%, #000000 50%);
}

.swatch-ipsvm-light {
  /* IpSVM light: iron gall (#15181e) on vellum (#eae6db) */
  background: linear-gradient(135deg, #15181e 50%, #eae6db 50%);
}

.swatch-ipsvm-dark {
  /* IpSVM dark: reversed (#e8e3d6) on dark ground (#08090b) */
  background: linear-gradient(135deg, #e8e3d6 50%, #08090b 50%);
}

/* Checkerboard backdrop for transparent swatches */
.checker-underlay {
  background-image:
    linear-gradient(45deg, #d8d3c5 25%, transparent 25%),
    linear-gradient(-45deg, #d8d3c5 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #d8d3c5 75%),
    linear-gradient(-45deg, transparent 75%, #d8d3c5 75%);
  background-size: 6px 6px;
  background-position: 0 0, 0 3px, 3px -3px, -3px 0;
}

.swatch-trans-bg-black {
  /* Trans bg, black fg */
  background:
    linear-gradient(135deg, #000000 50%, transparent 50%),
    linear-gradient(45deg, #ccc 25%, transparent 25%),
    linear-gradient(-45deg, #ccc 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #ccc 75%),
    linear-gradient(-45deg, transparent 75%, #ccc 75%);
  background-size: 100% 100%, 6px 6px, 6px 6px, 6px 6px, 6px 6px;
  background-position: 0 0, 0 0, 0 3px, 3px -3px, -3px 0;
}

.swatch-trans-fg-white {
  /* Trans fg, white bg */
  background:
    linear-gradient(135deg, transparent 50%, #ffffff 50%),
    linear-gradient(45deg, #ccc 25%, transparent 25%),
    linear-gradient(-45deg, #ccc 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #ccc 75%),
    linear-gradient(-45deg, transparent 75%, #ccc 75%);
  background-size: 100% 100%, 6px 6px, 6px 6px, 6px 6px, 6px 6px;
  background-position: 0 0, 0 0, 0 3px, 3px -3px, -3px 0;
}

.swatch-trans-bg-ipsvm {
  /* Trans bg, IpSVM dark fg (#08090b) */
  background:
    linear-gradient(135deg, #08090b 50%, transparent 50%),
    linear-gradient(45deg, #ccc 25%, transparent 25%),
    linear-gradient(-45deg, #ccc 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #ccc 75%),
    linear-gradient(-45deg, transparent 75%, #ccc 75%);
  background-size: 100% 100%, 6px 6px, 6px 6px, 6px 6px, 6px 6px;
  background-position: 0 0, 0 0, 0 3px, 3px -3px, -3px 0;
}

.swatch-trans-fg-ipsvm {
  /* Trans fg, IpSVM light bg (#eae6db) */
  background:
    linear-gradient(135deg, transparent 50%, #eae6db 50%),
    linear-gradient(45deg, #ccc 25%, transparent 25%),
    linear-gradient(-45deg, #ccc 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #ccc 75%),
    linear-gradient(-45deg, transparent 75%, #ccc 75%);
  background-size: 100% 100%, 6px 6px, 6px 6px, 6px 6px, 6px 6px;
  background-position: 0 0, 0 0, 0 3px, 3px -3px, -3px 0;
}

/* ------------------------------------------------------------------ Advanced Section */
.advanced-section {
  border-top: 1px solid var(--site-rule);
  padding-top: 0.85rem;
}

.advanced-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  list-style: none;
  user-select: none;
  padding: 0.25rem 0;
  color: var(--site-quiet);
  transition: color 150ms var(--ease-settle);
}

.advanced-summary::-webkit-details-marker {
  display: none;
}

.advanced-summary:hover {
  color: var(--site-text);
}

.summary-text {
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.summary-icon {
  transition: transform 200ms var(--ease-settle);
}

.advanced-section[open] .summary-icon {
  transform: rotate(180deg);
}

.advanced-body {
  padding-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.sub-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.sub-label {
  font-size: 0.6875rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--site-quiet);
}

.pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.pill-btn {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  padding: 0.4rem 0.75rem;
  background-color: var(--site-raised);
  border: 1px solid var(--site-rule);
  border-radius: 8px;
  color: var(--site-quiet);
  cursor: pointer;
  transition: all 140ms var(--ease-settle);
}

.pill-btn:hover {
  border-color: var(--site-text);
  color: var(--site-text);
}

.pill-btn.is-active {
  background-color: var(--site-text);
  border-color: var(--site-text);
  color: var(--site-ground);
  font-weight: 500;
}

/* Membership Notice */
.member-notice {
  font-size: 0.75rem;
  line-height: 1.45;
  color: var(--site-quiet);
  font-style: normal;
  margin-top: 0.45rem;
  padding: 0.4rem 0.65rem;
  background-color: var(--site-well);
  border-left: 2px solid var(--site-bronze);
  border-radius: 0 6px 6px 0;
}

.member-notice[hidden] {
  display: none !important;
}

/* File Dropzone */
.file-dropzone {
  display: block;
  padding: 0.65rem 0.85rem;
  border: 1px dashed var(--site-rule);
  background-color: var(--site-raised);
  color: var(--site-quiet);
  font-size: 0.8125rem;
  text-align: center;
  cursor: pointer;
  margin-top: 0.4rem;
  transition: border-color 150ms var(--ease-settle), color 150ms var(--ease-settle);
}

.file-dropzone:hover {
  border-color: var(--site-bronze);
  color: var(--site-text);
}

/* Logo Slider */
.logo-size-box {
  margin-top: 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.slider-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.slider-label {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--site-quiet);
}

.slider-val {
  font-size: 0.75rem;
  color: var(--site-text);
  font-variant-numeric: tabular-nums;
}

.range-slider {
  width: 100%;
  accent-color: var(--site-bronze);
  cursor: pointer;
}

/* Scannability Indicator */
.scannability-status {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.72rem;
  margin-top: 0.35rem;
  color: var(--site-quiet);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.status-ok {
  background-color: #2c6a3b;
}

.status-warn {
  background-color: #a0301f;
}

/* ------------------------------------------------------------------ Buttons */
.action-generate {
  margin-top: 0.25rem;
}

.btn-generate {
  width: 100%;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: none;
  color: #ffffff;
  background-color: var(--site-porphyry);
  border: 1px solid #5a222a;
  border-radius: 8px;
  padding: 0.78rem 1.25rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: background-color 160ms var(--ease-settle), transform 120ms var(--ease-settle);
}

.btn-generate:hover {
  background-color: var(--site-porphyry-hover);
}

.btn-generate:active {
  transform: translateY(1px);
}

/* ------------------------------------------------------------------ Right Preview Card */
.preview-column {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Sticky on desktop viewports where card fits on screen without overflowing */
@media (min-width: 769px) and (min-height: 560px) {
  .preview-column {
    position: sticky;
    top: 4.5rem;
    align-self: start;
  }
}

.preview-card {
  width: 100%;
  background-color: var(--site-raised);
  border: 1px solid var(--site-rule);
  border-radius: 8px;
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}

.qr-canvas-holder {
  width: 20.5rem;
  height: 20.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  border: 1px solid var(--site-rule-subtle);
  border-radius: 6px;
  overflow: hidden;
  user-select: none;
  /* Checkerboard pattern so transparency in the QR code is visibly obvious in the preview */
  background-image:
    linear-gradient(45deg, #e4dfd3 25%, transparent 25%),
    linear-gradient(-45deg, #e4dfd3 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e4dfd3 75%),
    linear-gradient(-45deg, transparent 75%, #e4dfd3 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}

#qr-preview-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  cursor: grab;
  /* Ensure image dragging is clean */
  -webkit-user-drag: element;
  user-drag: element;
}

#qr-preview-img:active {
  cursor: grabbing;
}

.qr-loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(234, 230, 219, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8125rem;
  color: var(--site-quiet);
}

.qr-loading-overlay[hidden] {
  display: none !important;
}

.download-bar {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.btn-download {
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--site-text);
  background-color: var(--site-ground);
  border: 1px solid var(--site-rule);
  border-radius: 8px;
  padding: 0.65rem 0.95rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  cursor: pointer;
  transition: all 140ms var(--ease-settle);
}

.btn-download:hover {
  background-color: var(--site-raised);
  border-color: var(--site-bronze);
  color: var(--site-bronze);
}

/* ------------------------------------------------------------------ Footer */
.site-footer {
  border-top: 1px solid var(--site-rule);
  padding: 1.25rem 1.5rem;
  color: var(--site-faint);
  font-size: 0.75rem;
  letter-spacing: 0.02em;
  text-align: center;
}

.footer-inner {
  max-width: 62rem;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

/* ------------------------------------------------------------------ Responsive */
@media (max-width: 768px) {
  .generator-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .preview-column {
    order: 2;
  }

  .qr-canvas-holder {
    width: 18rem;
    height: 18rem;
  }
}

@media (max-width: 480px) {
  .main-wrapper {
    padding: 1.5rem 1rem 2.5rem;
  }

  .header-inner {
    padding: 0.65rem 1rem;
  }

  .download-bar {
    grid-template-columns: 1fr;
  }

  .qr-canvas-holder {
    width: 15.5rem;
    height: 15.5rem;
  }
}
