:root {
  --bg: #e8dfcd;
  --paper: #f8f3e7;
  --paper-2: #efe6d3;
  --ink: #2a2622;
  --ink-soft: #5a5147;
  --gold: #b79a5b;

  /* 封蝋（既定: 深いボルドー）。?seal=gold で切替 */
  --seal: #6e1f2c;
  --seal-hi: #9c3b4a;
  --seal-lo: #3f0e18;
  --seal-ink: rgba(255, 236, 228, 0.72);

  --W: min(88vw, 400px);
  --ph: max(15.5rem, calc(var(--W) * 0.74));
  --seal-size: 3.9rem;

  --font-ja: "Shippori Mincho", "Hiragino Mincho ProN", "Yu Mincho", serif;
  --font-en: "Cormorant Garamond", "Times New Roman", serif;
}

:root[data-seal="gold"] {
  --seal: #b99c60;
  --seal-hi: #dcc790;
  --seal-lo: #7b6434;
  --seal-ink: rgba(72, 54, 22, 0.7);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100svh;
  font-family: var(--font-ja);
  color: var(--ink);
  background: radial-gradient(130% 90% at 18% 8%, #f2eadb 0, var(--bg) 55%, #dcd1ba 100%);
  background-attachment: fixed;
}

/* 紙: ごく細かい繊維だけ。ざらつきは使わない */
.paper {
  background-color: var(--paper);
  background-image:
    repeating-linear-gradient(97deg, rgba(120, 100, 70, 0.022) 0 1px, transparent 1px 7px),
    repeating-linear-gradient(83deg, rgba(120, 100, 70, 0.018) 0 1px, transparent 1px 11px),
    repeating-linear-gradient(172deg, rgba(120, 100, 70, 0.014) 0 1px, transparent 1px 5px),
    linear-gradient(135deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 55%);
}

/* ---------- 封筒 ---------- */
.env {
  position: relative;
  width: var(--W);
  height: var(--ph);
}

.env-back,
.env-front > i,
.flap {
  position: absolute;
  inset: 0;
}

.env-back {
  z-index: 1;
  background-color: var(--paper-2);
  background-image: linear-gradient(135deg, rgba(255, 255, 255, 0.4), rgba(0, 0, 0, 0.04));
  box-shadow: 6px 14px 34px -14px rgba(70, 50, 30, 0.32), 1px 2px 4px rgba(70, 50, 30, 0.1);
}

.env-front { position: absolute; inset: 0; z-index: 3; }
.env-front > i { display: block; }
.env-front .f-l { clip-path: polygon(0 0, 50% 55%, 0 100%); background: linear-gradient(100deg, #fbf7ec, #f1e9d7); }
.env-front .f-r { clip-path: polygon(100% 0, 50% 55%, 100% 100%); background: linear-gradient(80deg, #efe6d3, #e6dcc6); }
.env-front .f-b { clip-path: polygon(0 100%, 50% 55%, 100% 100%); background: linear-gradient(180deg, #f3ebda, #ebe2cd); }

.flap {
  z-index: 4;
  height: 55%;
  bottom: auto;
  transform-origin: 50% 0;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  background: linear-gradient(160deg, #fcf8ee, #f0e7d4);
}

/* ---------- 封蝋 ---------- */
.seal {
  position: absolute;
  z-index: 6;
  left: 50%;
  top: calc(var(--ph) * 0.55 - var(--seal-size) / 2);
  width: var(--seal-size);
  height: var(--seal-size);
  margin-left: calc(var(--seal-size) / -2);
  filter: drop-shadow(2px 4px 4px rgba(40, 10, 15, 0.3));
}

.seal-half {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, var(--seal-hi) 0, var(--seal) 46%, var(--seal-lo) 100%);
  box-shadow: inset 0 0 0 0.28rem rgba(0, 0, 0, 0.05), inset 1px 1px 2px rgba(255, 255, 255, 0.22);
}

.seal-half::before {
  content: "";
  position: absolute;
  inset: 0.5rem;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.16);
  box-shadow: 0.5px 0.5px 0 rgba(255, 255, 255, 0.14);
}

.seal-half b {
  font: 500 1.7rem/1 var(--font-en);
  color: var(--seal-ink);
  text-shadow: 0.5px 0.5px 0 rgba(255, 255, 255, 0.18), -0.5px -0.5px 0 rgba(0, 0, 0, 0.3);
}

.seal-half.l { clip-path: polygon(0 0, 52.6% 0, 47.6% 22%, 55.6% 40%, 46.6% 62%, 53.6% 80%, 49.6% 100%, 0 100%); }
.seal-half.r { clip-path: polygon(52% 0, 100% 0, 100% 100%, 49% 100%, 53% 80%, 46% 62%, 55% 40%, 47% 22%); }

/* 文字の質感 */
.foil {
  background: linear-gradient(115deg, #2b2622 0 38%, #7d6a45 50%, #2b2622 62% 100%);
  background-size: 260% 100%;
  background-position: 30% 0;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.press {
  color: #3a342d;
  text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.7), -0.5px -0.5px 0 rgba(0, 0, 0, 0.16);
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
