:root {
  --drawer: #141b28;
  --drawer-2: #1a2230;
  --slot: #0e1420;
  --paper: #e7ebf0;
  --paper-verso: #dfe4ea;
  --graphite: #2a3344;
  --pencil: #5a6578;
  --line: rgba(231, 235, 240, 0.12);
  --accent: #7eb8c9;
  --accent-hot: #c9a87e;
  --warn: #c98a7e;
  --ok: #8cb89a;
  --font-display: "Avenir Next", "Segoe UI", "Helvetica Neue", sans-serif;
  --font-body: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --font-pencil: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}

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

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--drawer);
  color: var(--paper);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
}

body {
  position: relative;
  overflow-x: hidden;
}

.drawer {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(1200px 700px at 50% -10%, #243044 0%, transparent 55%),
    linear-gradient(180deg, var(--drawer-2), var(--drawer) 55%, #0f1520);
}

.drawer::before {
  content: "";
  position: absolute;
  inset: 12vh 8vw auto;
  height: 42vh;
  border-radius: 10px 10px 4px 4px;
  background:
    repeating-linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.03) 0 1px,
      transparent 1px 48px
    ),
    linear-gradient(180deg, #1e2838, var(--slot));
  box-shadow:
    inset 0 18px 40px rgba(0, 0, 0, 0.45),
    0 30px 80px rgba(0, 0, 0, 0.35);
  opacity: 0.9;
}

.grain {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.07;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
}

.shell {
  position: relative;
  z-index: 2;
  width: min(720px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 7vh 0 4rem;
}

.hero {
  max-width: 34rem;
  animation: rise 0.85s ease-out both;
}

.brand {
  margin: 0 0 1.1rem;
  font-family: var(--font-display);
  font-size: clamp(2.35rem, 7vw, 3.4rem);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 0.95;
  color: var(--paper);
}

.brand::after {
  content: "";
  display: block;
  width: 3.25rem;
  height: 2px;
  margin-top: 0.85rem;
  background: linear-gradient(90deg, var(--accent), transparent);
  animation: draw 1.1s ease-out 0.2s both;
}

h1 {
  margin: 0 0 0.85rem;
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 3.4vw, 1.75rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.25;
  color: rgba(231, 235, 240, 0.92);
}

.lede {
  margin: 0;
  max-width: 32rem;
  color: rgba(231, 235, 240, 0.68);
  font-size: 1.02rem;
}

.stage {
  margin-top: 2.75rem;
  animation: rise 0.95s ease-out 0.12s both;
}

.deck {
  perspective: 1400px;
  margin: 0 auto;
  width: min(100%, 420px);
}

.card {
  position: relative;
  width: 100%;
  aspect-ratio: 5 / 3.4;
  min-height: 260px;
  transform-style: preserve-3d;
  transition: transform 0.7s cubic-bezier(0.22, 0.9, 0.25, 1);
  border-radius: 6px;
}

.card.is-flipped {
  transform: rotateY(180deg);
}

.side {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 6px;
  padding: 1.1rem 1.15rem 0.95rem;
  display: flex;
  flex-direction: column;
  box-shadow:
    0 18px 50px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.face {
  background:
    linear-gradient(165deg, #f2f4f7 0%, var(--paper) 45%, #dde3ea 100%);
  color: var(--graphite);
  padding-bottom: 0.75rem;
}

.photo-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  border-radius: 3px;
  overflow: hidden;
  background: #2a3344;
  box-shadow: inset 0 0 0 1px rgba(42, 51, 68, 0.12);
}

#photo {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.printed {
  margin: 0.65rem 0 0.15rem;
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--graphite);
  line-height: 1.25;
}

.printed-sub {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--pencil);
}

.verso {
  background:
    linear-gradient(200deg, #e8edf3 0%, var(--paper-verso) 50%, #d5dbe3 100%);
  color: var(--graphite);
  transform: rotateY(180deg);
}

.side-label {
  margin: 0 0 0.45rem;
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--pencil);
  font-weight: 600;
}

textarea {
  flex: 1;
  width: 100%;
  border: 0;
  resize: none;
  background: transparent;
  color: inherit;
  font: inherit;
  line-height: 1.45;
  outline: none;
  padding: 0;
}

.verso textarea {
  font-family: var(--font-pencil);
  font-size: 1.08rem;
  font-style: italic;
  color: #3a4558;
}

.rule {
  margin: 0.55rem 0 0;
  font-size: 0.78rem;
  color: var(--pencil);
  font-family: var(--font-pencil);
  font-style: italic;
  position: relative;
}

.rule::before {
  content: "";
  position: absolute;
  left: 0;
  bottom: -0.35rem;
  width: 0;
  height: 1px;
  background: var(--accent-hot);
  transition: width 0.6s ease;
}

.verso:focus-within .rule::before,
.card.is-flipped .rule::before {
  width: 42%;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  justify-content: center;
  margin-top: 1.35rem;
}

.cta,
.ghost {
  appearance: none;
  border: 0;
  cursor: pointer;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  padding: 0.7rem 1rem;
  border-radius: 4px;
  transition: transform 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.cta {
  background: var(--accent);
  color: #102028;
}

.cta:hover {
  transform: translateY(-1px);
  background: #93c7d5;
}

.ghost {
  background: transparent;
  color: rgba(231, 235, 240, 0.85);
  border: 1px solid var(--line);
}

.ghost:hover {
  background: rgba(231, 235, 240, 0.06);
}

.ghost.danger {
  color: rgba(201, 138, 126, 0.95);
  border-color: rgba(201, 138, 126, 0.35);
}

.status,
.softness {
  text-align: center;
  margin: 0.9rem 0 0;
  min-height: 1.4em;
  font-size: 0.9rem;
  color: rgba(231, 235, 240, 0.7);
}

.softness {
  color: var(--warn);
  max-width: 34rem;
  margin-left: auto;
  margin-right: auto;
}

.softness.ok {
  color: var(--ok);
}

.how {
  margin-top: 3.5rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--line);
  animation: rise 1s ease-out 0.2s both;
}

.how h2 {
  margin: 0 0 0.75rem;
  font-size: 1.05rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.how ul {
  margin: 0;
  padding-left: 1.15rem;
  color: rgba(231, 235, 240, 0.72);
}

.how li {
  margin-bottom: 0.4rem;
}

.fine {
  margin: 1rem 0 0;
  font-size: 0.82rem;
  color: rgba(231, 235, 240, 0.45);
}

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

.print-sheet {
  display: none;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes draw {
  from {
    width: 0;
  }
  to {
    width: 3.25rem;
  }
}

@media (max-width: 560px) {
  .shell {
    padding-top: 5vh;
  }

  .card {
    min-height: 280px;
    aspect-ratio: auto;
    height: 300px;
  }

  .controls {
    flex-direction: column;
  }

  .cta,
  .ghost {
    width: 100%;
  }
}

@media print {
  body * {
    visibility: hidden;
  }

  .print-sheet,
  .print-sheet * {
    visibility: visible;
  }

  .print-sheet {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    position: absolute;
    inset: 0;
    padding: 1rem;
    background: white;
    color: #222;
  }

  .print-face,
  .print-verso {
    border: 1px solid #bbb;
    min-height: 70vh;
    padding: 1.25rem;
  }

  .print-face img {
    display: block;
    width: 100%;
    height: auto;
    margin-bottom: 1rem;
  }

  .print-verso {
    background: #f3f3f3;
  }

  .print-brand {
    margin: 0 0 1rem;
    font-size: 0.75rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #666;
  }

  .print-body {
    margin: 0;
    white-space: pre-wrap;
    font-size: 1.05rem;
    line-height: 1.5;
  }

  .print-verso .print-body {
    font-family: Georgia, serif;
    font-style: italic;
  }

  .print-rule {
    margin-top: 2rem;
    font-style: italic;
    color: #666;
    font-size: 0.85rem;
  }
}
