/* =========================================================
   In-story documents — "ic-doc" component
   -----------------------------------------------------------
   Drop one of these inside .chapter-prose and it reads as a
   physical page sitting on top of the glass frame: letters,
   mission orders, plain notes.

   Load AFTER styles.css:
     <link rel="stylesheet" href="../css/styles.css" />
     <link rel="stylesheet" href="../css/documents.css" />

   Base markup:
     <div class="ic-doc ic-doc--letter">
       <div class="ic-doc__meta">Limsa Lominsa, 9th Sun</div>
       <div class="ic-doc__body">
         <p class="ic-doc__salutation">My dearest Susule,</p>
         <p>…</p>
       </div>
       <p class="ic-doc__sign">— Aline</p>
     </div>

   Three ready variants (combine with the base class):
     .ic-doc--letter   warm, handwritten-feel, optional wax seal
     .ic-doc--mission  typed orders, routing header, stamp
     .ic-doc--plain    a plain, undecorated note
   ========================================================= */

.ic-doc {
  position: relative;
  z-index: 2; /* sits above .frame::before / ::after glass layers */
  width: min(100%, 540px);
  margin: 2.5rem auto;
  padding: 2rem 2.25rem 1.75rem;
  color: #241a10;
  background: linear-gradient(170deg, #f6ecd2 0%, #ecdfb8 100%);
  border-radius: 3px;
  box-shadow:
    0 2px 0 rgba(255, 255, 255, 0.5) inset,
    0 18px 38px rgba(0, 0, 0, 0.5),
    0 2px 6px rgba(0, 0, 0, 0.35);
  transform: rotate(-0.6deg);
  font-family: var(--font-display);
}

.ic-doc + .ic-doc {
  transform: rotate(0.5deg);
}

/* faint paper grain + fold creases (two horizontal thirds) */
.ic-doc::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background:
    linear-gradient(
      rgba(0, 0, 0, 0.06) 0,
      rgba(0, 0, 0, 0.06) 1px,
      transparent 1px,
      transparent 33.3%
    ),
    linear-gradient(
      rgba(0, 0, 0, 0.06) 0,
      rgba(0, 0, 0, 0.06) 1px,
      transparent 1px,
      transparent 66.6%
    ),
    repeating-linear-gradient(
      128deg,
      rgba(0, 0, 0, 0.025) 0px,
      rgba(0, 0, 0, 0.025) 1px,
      transparent 1px,
      transparent 3px
    );
  background-size: 100% 100%, 100% 100%, auto;
  mix-blend-mode: multiply;
}

/* dog-eared corner (folded page) */
.ic-doc::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 26px 26px 0;
  border-color: transparent rgba(0, 0, 0, 0.22) transparent transparent;
  filter: drop-shadow(-1px 1px 1px rgba(0, 0, 0, 0.25));
}

.ic-doc__meta {
  position: relative;
  z-index: 1;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #6b5a3a;
  text-align: right;
  margin-bottom: 1rem;
}

.ic-doc__body {
  position: relative;
  z-index: 1;
  font-size: 1.02rem;
  line-height: 1.7;
}

.ic-doc__body p {
  margin: 0 0 1rem;
}

.ic-doc__salutation {
  font-style: italic;
  font-size: 1.08rem;
  margin-bottom: 1.1rem !important;
}

.ic-doc__sign {
  position: relative;
  z-index: 1;
  text-align: right;
  font-style: italic;
  font-size: 1.15rem;
  margin: 1.1rem 0 0;
}

.ic-doc__ps {
  position: relative;
  z-index: 1;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(36, 26, 16, 0.2);
  font-size: 0.92rem;
  font-style: italic;
  color: #4a3c22;
}

/* -------- letter / love-letter variant -------- */

.ic-doc--letter .ic-doc__sign,
.ic-doc--love .ic-doc__sign {
  font-family: "Segoe Script", "Brush Script MT", var(--font-display);
  font-size: 1.4rem;
}

.ic-doc--love {
  background: linear-gradient(170deg, #f8e7e4 0%, #efd3cf 100%);
}

.ic-doc--love .ic-doc__body {
  color: #3a2016;
}

/* optional wax seal — add <span class="ic-doc__seal ic-doc__seal--aline">A</span>
   as the first child of .ic-doc */
.ic-doc__seal {
  position: absolute;
  top: -16px;
  right: 28px;
  z-index: 3;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  color: rgba(255, 255, 255, 0.85);
  background: radial-gradient(circle at 35% 30%, var(--seal-color, var(--gold-dim)), color-mix(in srgb, var(--seal-color, var(--gold-dim)) 60%, black) 85%);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.5), inset 0 1px 1px rgba(255, 255, 255, 0.4);
  transform: rotate(-8deg);
}

.ic-doc__seal--aline  { --seal-color: var(--pov-aline); }
.ic-doc__seal--susule { --seal-color: #8a8378; }
.ic-doc__seal--lihua  { --seal-color: var(--pov-lihua); }

/* -------- mission / orders variant -------- */

.ic-doc--mission {
  background: linear-gradient(170deg, #ded7c0 0%, #c9c2a7 100%);
  color: #1c1a12;
  font-family: "Courier New", Courier, monospace;
  transform: rotate(0deg);
  border: 1px solid rgba(0, 0, 0, 0.25);
}

.ic-doc--mission::after {
  /* square corner, no dog-ear — orders don't get folded romantically */
  content: none;
}

.ic-doc--mission .ic-doc__head {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.25rem 0.75rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px dashed rgba(0, 0, 0, 0.35);
  padding-bottom: 0.85rem;
  margin-bottom: 1.1rem;
}

.ic-doc--mission .ic-doc__head dt {
  font-weight: 700;
  opacity: 0.75;
}

.ic-doc--mission .ic-doc__head dd {
  margin: 0;
}

.ic-doc--mission .ic-doc__body {
  font-size: 0.98rem;
  line-height: 1.65;
}

.ic-doc--mission .ic-doc__sign {
  font-family: "Courier New", Courier, monospace;
  font-style: normal;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.95rem;
}

/* diagonal classification stamp — add
   <span class="ic-doc__stamp ic-doc__stamp--classified">Confidential</span> */
.ic-doc__stamp {
  position: absolute;
  top: 18px;
  right: -8px;
  z-index: 3;
  padding: 0.3rem 1.1rem;
  font-family: "Courier New", Courier, monospace;
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  border: 2px solid var(--stamp-color, var(--danger));
  color: var(--stamp-color, var(--danger));
  background: rgba(255, 255, 255, 0.08);
  transform: rotate(8deg);
  opacity: 0.85;
}

.ic-doc__stamp--classified { --stamp-color: var(--danger); }
.ic-doc__stamp--urgent     { --stamp-color: var(--gold-dim); }
.ic-doc__stamp--approved   { --stamp-color: #4c7a4c; }

/* -------- plain variant -------- */

.ic-doc--plain {
  background: linear-gradient(170deg, #f1ead8 0%, #e4dac0 100%);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.4) inset,
    0 10px 24px rgba(0, 0, 0, 0.4);
  transform: none;
}

.ic-doc--plain::after {
  content: none;
}

.ic-doc--plain .ic-doc__body {
  font-size: 1rem;
}

/* -------- small screens -------- */

@media (max-width: 540px) {
  .ic-doc {
    padding: 1.5rem 1.35rem 1.35rem;
    transform: none;
  }
  .ic-doc__stamp {
    right: -4px;
    font-size: 0.72rem;
    padding: 0.25rem 0.8rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ic-doc {
    transform: none;
  }
}
