/* ===================================================================
   CLOSED AGENCY ARCHIVE — Medieval / Dark Fantasy Theme
   =================================================================== */

:root {
  --bg: #050505;
  --panel: #0d0f0d;
  --panel-alt: #101210;
  --emerald: #1f8f52;
  --emerald-bright: #3fe08a;
  --emerald-dim: #12472b;
  --text-main: #eef1ee;
  --text-soft: #b7c2ba;
  --border-hair: rgba(63, 224, 138, 0.18);
  --font-display: 'Cinzel Decorative', serif;
  --font-heading: 'Cinzel', serif;
  --font-body: 'EB Garamond', serif;

  /* Heraldic "diaper" lattice pattern — classic medieval textile/wall motif */
  --diaper-pattern:
    linear-gradient(45deg, rgba(63,224,138,0.055) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(63,224,138,0.055) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(63,224,138,0.055) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(63,224,138,0.055) 75%);
  --diaper-size4: 30px 30px, 30px 30px, 30px 30px, 30px 30px;
  --diaper-pos4: 0 0, 0 15px, 15px -15px, -15px 0px;

  /* Fine cross-hatch, used inside smaller/denser surfaces (table header, buttons) */
  --hatch-pattern:
    repeating-linear-gradient(45deg, rgba(63,224,138,0.08) 0 1px, transparent 1px 9px),
    repeating-linear-gradient(-45deg, rgba(63,224,138,0.08) 0 1px, transparent 1px 9px);
}

/* Castle "battlement" accent bar — reusable on any relatively-positioned box */
.battlement {
  position: absolute;
  left: 0;
  right: 0;
  height: 10px;
  background-image: repeating-linear-gradient(90deg, var(--emerald) 0 16px, transparent 16px 32px);
  opacity: 0.55;
}
.battlement.top { top: 0; }
.battlement.bottom { bottom: 0; }

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text-main);
  font-family: var(--font-body);
  overflow-x: hidden;
  position: relative;
}

/* Ancient paper / grain texture overlay across the whole page */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  opacity: 0.09;
  mix-blend-mode: overlay;
  background-image:
    repeating-linear-gradient(0deg, rgba(255,255,255,0.45) 0px, transparent 1px, transparent 2px),
    repeating-linear-gradient(90deg, rgba(255,255,255,0.22) 0px, transparent 1px, transparent 3px),
    radial-gradient(ellipse at 20% 15%, rgba(120,90,40,0.35) 0%, transparent 45%),
    radial-gradient(ellipse at 82% 78%, rgba(120,90,40,0.28) 0%, transparent 50%);
}

/* Ambient candlelight vignette that frames every page, not just the intro */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(31,143,82,0.07) 0%, transparent 40%),
    radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,0.55) 100%);
}

.hidden { display: none !important; }

/* ===================================================================
   FOG + DUST AMBIENCE
=================================================================== */

.fog-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.fog {
  position: absolute;
  width: 160%;
  height: 160%;
  background: radial-gradient(ellipse at center, rgba(31,143,82,0.10) 0%, rgba(5,5,5,0) 60%);
  filter: blur(30px);
  opacity: 0.7;
}

.fog-1 { top: -30%; left: -30%; animation: drift1 38s linear infinite; }
.fog-2 { top: 20%; left: -50%; animation: drift2 52s linear infinite; }
.fog-3 { top: -10%; left: 10%; animation: drift3 65s linear infinite; }

@keyframes drift1 {
  0%   { transform: translate(0, 0) rotate(0deg); }
  50%  { transform: translate(6%, 4%) rotate(8deg); }
  100% { transform: translate(0, 0) rotate(0deg); }
}
@keyframes drift2 {
  0%   { transform: translate(0, 0) rotate(0deg); }
  50%  { transform: translate(-5%, 5%) rotate(-6deg); }
  100% { transform: translate(0, 0) rotate(0deg); }
}
@keyframes drift3 {
  0%   { transform: translate(0, 0) rotate(0deg); }
  50%  { transform: translate(4%, -6%) rotate(5deg); }
  100% { transform: translate(0, 0) rotate(0deg); }
}

#dust-canvas {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

/* ===================================================================
   OPENING / INTRO SCREEN
=================================================================== */

#intro-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  background:
    var(--diaper-pattern),
    radial-gradient(ellipse at center, #0a0d0a 0%, #050505 70%),
    linear-gradient(#050505, #050505);
  background-size: var(--diaper-size4), auto, auto;
  background-position: var(--diaper-pos4), center, center;
  transition: opacity 1.6s ease;
  padding: 24px;
  text-align: center;
  overflow: hidden;
}

#intro-screen.fade-out {
  opacity: 0;
  pointer-events: none;
}

.intro-vignette {
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse at center, transparent 40%, rgba(0,0,0,0.75) 100%);
  pointer-events: none;
}

/* Iron corner flourishes */
.intro-corner {
  position: absolute;
  width: 90px;
  height: 90px;
  opacity: 0.65;
  z-index: 2;
}
.intro-corner.tl { top: 18px; left: 18px; }
.intro-corner.tr { top: 18px; right: 18px; transform: scaleX(-1); }
.intro-corner.bl { bottom: 18px; left: 18px; transform: scaleY(-1); }
.intro-corner.br { bottom: 18px; right: 18px; transform: scale(-1, -1); }

/* Wall torches */
.torch {
  position: absolute;
  top: 12%;
  width: 10px;
  height: 90px;
  background: linear-gradient(180deg, #2a1e12, #14100b);
  border: 1px solid rgba(63,224,138,0.2);
  border-radius: 2px;
  z-index: 2;
}
.torch-left { left: 8%; }
.torch-right { right: 8%; }
.torch .flame {
  position: absolute;
  top: -34px;
  left: 50%;
  transform: translateX(-50%);
  width: 22px;
  height: 34px;
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  background: radial-gradient(ellipse at 50% 70%, #eafff2 0%, var(--emerald-bright) 35%, var(--emerald) 65%, transparent 75%);
  filter: blur(0.5px);
  animation: flicker 2.6s ease-in-out infinite;
  box-shadow: 0 0 24px 8px rgba(63,224,138,0.45);
}
@keyframes flicker {
  0%, 100% { transform: translateX(-50%) scale(1) rotate(-1deg); opacity: 0.9; }
  20%      { transform: translateX(-48%) scale(0.94, 1.05) rotate(2deg); opacity: 1; }
  45%      { transform: translateX(-52%) scale(1.05, 0.96) rotate(-2deg); opacity: 0.85; }
  70%      { transform: translateX(-49%) scale(0.97, 1.03) rotate(1deg); opacity: 1; }
}

.intro-crest-row { position: relative; z-index: 2; }
.crest-glyph {
  font-size: 1.6rem;
  color: var(--emerald-bright);
  text-shadow: 0 0 16px rgba(63,224,138,0.6);
  display: inline-block;
  animation: pulse-glow 3.5s ease-in-out infinite;
}

.intro-portrait-frame {
  position: relative;
  width: min(300px, 62vw);
  height: min(300px, 62vw);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.frame-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  animation: spin 120s linear infinite;
}

.intro-portrait {
  width: 84%;
  height: 84%;
  object-fit: cover;
  border-radius: 50%;
  border: 2px solid var(--emerald);
  box-shadow: 0 0 30px 6px rgba(63, 224, 138, 0.35), 0 0 80px 20px rgba(31,143,82,0.15);
  animation: breathe 4s ease-in-out infinite;
  position: relative;
  z-index: 2;
}

@keyframes breathe {
  0%, 100% { box-shadow: 0 0 30px 6px rgba(63, 224, 138, 0.30), 0 0 80px 20px rgba(31,143,82,0.12); }
  50%      { box-shadow: 0 0 44px 10px rgba(63, 224, 138, 0.55), 0 0 110px 30px rgba(31,143,82,0.22); }
}

.intro-banner {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--emerald-bright);
}
.banner-rule {
  width: 46px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--emerald-bright), transparent);
}
.banner-text {
  font-family: var(--font-heading);
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-size: 0.78rem;
  text-shadow: 0 0 12px rgba(63,224,138,0.5);
}

.intro-verse {
  font-family: var(--font-heading);
  font-weight: 500;
  letter-spacing: 0.06em;
  font-size: clamp(0.95rem, 2vw, 1.25rem);
  color: var(--text-soft);
  line-height: 1.9;
  text-shadow: 0 0 12px rgba(63,224,138,0.25);
  max-width: 640px;
  position: relative;
  z-index: 2;
}

.intro-seal-wax {
  position: relative;
  z-index: 2;
  font-size: 1.4rem;
  color: var(--emerald);
  opacity: 0.8;
  text-shadow: 0 0 14px rgba(31,143,82,0.6);
}

.intro-seal {
  position: absolute;
  width: 460px;
  height: 460px;
  border-radius: 50%;
  border: 1px solid var(--border-hair);
  animation: spin 90s linear infinite;
  z-index: 1;
}
.intro-seal::before, .intro-seal::after {
  content: "";
  position: absolute;
  inset: 30px;
  border-radius: 50%;
  border: 1px dashed rgba(63,224,138,0.15);
}
.intro-seal::after { inset: 55px; animation: spin 60s linear infinite reverse; }

@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.intro-glow {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(31,143,82,0.12) 0%, transparent 55%);
  pointer-events: none;
  z-index: 1;
}

@media (max-width: 720px) {
  .torch { display: none; }
  .intro-corner { width: 60px; height: 60px; }
}

/* ===================================================================
   MAIN SITE LAYOUT
=================================================================== */

#main-site {
  position: relative;
  z-index: 3;
  opacity: 0;
  animation: reveal 1.4s ease forwards;
}

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

.site-header {
  text-align: center;
  padding: 90px 20px 50px;
  position: relative;
  overflow: hidden;
}

.site-header::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: var(--diaper-pattern);
  background-size: var(--diaper-size4);
  background-position: var(--diaper-pos4);
  -webkit-mask-image: radial-gradient(ellipse 60% 90% at 50% 40%, black 0%, transparent 75%);
  mask-image: radial-gradient(ellipse 60% 90% at 50% 40%, black 0%, transparent 75%);
}

.site-header > *:not(.frame-corner):not(.battlement) { position: relative; z-index: 1; }

.crest {
  font-size: 2rem;
  color: var(--emerald-bright);
  text-shadow: 0 0 18px rgba(63,224,138,0.6);
  margin-bottom: 6px;
}

.site-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.1rem, 5vw, 3.4rem);
  margin: 0;
  color: var(--text-main);
  text-shadow: 0 0 22px rgba(63,224,138,0.35);
  letter-spacing: 0.03em;
}

.site-subtitle {
  font-family: var(--font-heading);
  color: var(--text-soft);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 0.8rem;
  margin: 14px 0 0;
}

.ornament-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin: 26px auto;
  max-width: 380px;
  color: var(--emerald);
}
.ornament-divider span {
  height: 1px;
  flex: 1;
  background: linear-gradient(90deg, transparent, var(--emerald), transparent);
  opacity: 0.6;
}
.ornament-divider i { font-style: normal; font-size: 1rem; text-shadow: 0 0 10px rgba(63,224,138,0.6); }
.ornament-divider.small { max-width: 220px; margin: 18px auto; }

/* Buttons */
.ghost-btn {
  font-family: var(--font-heading);
  background: transparent;
  color: var(--emerald-bright);
  border: 1px solid var(--emerald);
  padding: 12px 30px;
  letter-spacing: 0.08em;
  font-size: 0.85rem;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: 2px;
  transition: all 0.3s ease;
  position: relative;
}
.ghost-btn:hover {
  background-color: rgba(31,143,82,0.12);
  background-image: var(--hatch-pattern);
  box-shadow: 0 0 18px rgba(63,224,138,0.4);
  transform: translateY(-1px);
}
.ghost-btn.wide { width: 100%; margin-top: 10px; }

.link-btn {
  background: none;
  border: none;
  color: var(--emerald-bright);
  cursor: pointer;
  font-family: var(--font-body);
  font-style: italic;
  text-decoration: underline;
  padding: 0;
}

.admin-status {
  display: block;
  margin-top: 16px;
  color: var(--text-soft);
  font-family: var(--font-heading);
  font-size: 0.85rem;
  letter-spacing: 0.04em;
}

.sync-banner {
  max-width: 460px;
  margin: 14px auto 0;
  padding: 8px 14px;
  border: 1px solid rgba(224, 79, 63, 0.4);
  background: rgba(224, 79, 63, 0.08);
  color: #f2b8ae;
  font-family: var(--font-heading);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  border-radius: 2px;
}
.sync-banner.is-ok {
  border-color: var(--border-hair);
  background: rgba(63, 224, 138, 0.06);
  color: var(--text-soft);
}

/* ===== Search bar ===== */
.search-wrap {
  position: relative;
  max-width: 460px;
  margin: 32px auto 0;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 16px;
  color: var(--emerald);
  opacity: 0.8;
  font-size: 0.95rem;
  pointer-events: none;
}

.search-input {
  width: 100%;
  font-family: var(--font-body);
  font-style: italic;
  font-size: 1rem;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border-hair);
  color: var(--text-main);
  padding: 12px 40px 12px 40px;
  border-radius: 2px;
  outline: none;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}
.search-input::placeholder { color: var(--text-soft); opacity: 0.7; }
.search-input:focus {
  border-color: var(--emerald);
  box-shadow: 0 0 0 3px rgba(31,143,82,0.18), 0 0 16px rgba(63,224,138,0.15);
}

.search-clear {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  color: var(--text-soft);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}
.search-clear:hover { color: var(--emerald-bright); }

.search-result-count {
  margin: 10px 0 0;
  font-family: var(--font-heading);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-soft);
}

/* ===== Admin edit/delete controls on each record ===== */
.record-controls {
  display: inline-flex;
  gap: 6px;
}

.record-controls button {
  font-family: var(--font-heading);
  font-size: 0.68rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: transparent;
  border: 1px solid var(--border-hair);
  color: var(--text-soft);
  padding: 5px 9px;
  border-radius: 2px;
  cursor: pointer;
  transition: all 0.25s ease;
}
.record-controls .edit-btn:hover {
  color: var(--emerald-bright);
  border-color: var(--emerald);
  box-shadow: 0 0 10px rgba(63,224,138,0.25);
}
.record-controls .delete-btn:hover {
  color: #ff8b87;
  border-color: #a1443f;
  box-shadow: 0 0 10px rgba(255,90,80,0.2);
}

.empty-state {
  text-align: center;
  color: var(--text-soft);
  font-style: italic;
  font-size: 0.95rem;
  padding: 18px 0;
  opacity: 0.75;
}

.no-match { display: none !important; }

/* ===================================================================
   RECORD SECTIONS
=================================================================== */

main {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 24px 80px;
}

.record-section {
  margin-bottom: 90px;
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.9s ease, transform 0.9s ease;
}
.record-section.in-view { opacity: 1; transform: translateY(0); }

.section-frame {
  background:
    linear-gradient(180deg, var(--panel) 0%, var(--panel-alt) 100%);
  border: 1px solid var(--emerald-dim);
  outline: 1px solid rgba(63,224,138,0.08);
  outline-offset: -7px;
  border-radius: 2px;
  padding: 60px 34px 52px;
  text-align: center;
  position: relative;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.6), 0 20px 60px rgba(0,0,0,0.5), inset 0 0 40px rgba(0,0,0,0.4);
}

/* Heraldic diaper lattice sits quietly behind every panel's content */
.section-frame::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: var(--diaper-pattern);
  background-size: var(--diaper-size4);
  background-position: var(--diaper-pos4);
}

.section-frame > *:not(.frame-corner) { position: relative; z-index: 1; }

/* Medieval iron corner brackets — shared SVG ornament, positioned per corner */
.frame-corner {
  position: absolute;
  width: 46px;
  height: 46px;
  opacity: 0.6;
  z-index: 2;
  pointer-events: none;
}
.frame-corner.tl { top: 10px; left: 10px; }
.frame-corner.tr { top: 10px; right: 10px; transform: scaleX(-1); }
.frame-corner.bl { bottom: 10px; left: 10px; transform: scaleY(-1); }
.frame-corner.br { bottom: 10px; right: 10px; transform: scale(-1, -1); }

.section-portrait {
  width: 150px;
  height: 150px;
  object-fit: cover;
  border-radius: 50%;
  border: 1.5px solid var(--emerald);
  box-shadow: 0 0 22px rgba(63,224,138,0.3);
  margin-bottom: 20px;
}

.section-title {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 3vw, 2.1rem);
  color: var(--text-main);
  margin: 0;
  text-shadow: 0 0 16px rgba(63,224,138,0.3);
  letter-spacing: 0.04em;
}
.section-title::before, .section-title::after {
  content: "\2726";
  display: inline-block;
  color: var(--emerald);
  font-size: 0.55em;
  opacity: 0.75;
  vertical-align: middle;
  margin: 0 14px;
  text-shadow: 0 0 10px rgba(63,224,138,0.6);
}
.section-title.small-title { font-size: 1.3rem; }

.section-note {
  color: var(--text-soft);
  font-style: italic;
  font-size: 0.95rem;
  margin: 10px 0 0;
}

/* Record table — styled as a medieval ledger */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--emerald-dim);
  border-radius: 2px;
  box-shadow: inset 0 0 30px rgba(0,0,0,0.35);
}

.record-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 1rem;
  min-width: 460px;
}

.record-table thead th {
  font-family: var(--font-heading);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--emerald-bright);
  background-image: var(--hatch-pattern), linear-gradient(180deg, rgba(31,143,82,0.14), rgba(31,143,82,0.04));
  padding: 14px 18px;
  border-bottom: 1px solid var(--emerald-dim);
  text-shadow: 0 0 8px rgba(63,224,138,0.4);
  white-space: nowrap;
}
.record-table thead th.col-no { width: 56px; text-align: center; }

.record-table tbody tr {
  border-bottom: 1px solid var(--border-hair);
  transition: background 0.3s ease;
}
.record-table tbody tr:nth-child(even) { background: rgba(255,255,255,0.015); }
.record-table tbody tr:hover { background: rgba(31,143,82,0.09); }
.record-table tbody tr:last-child { border-bottom: none; }

.record-table td {
  padding: 13px 18px;
  color: var(--text-main);
  vertical-align: middle;
}

.record-table td.col-no {
  font-family: var(--font-heading);
  color: var(--emerald-bright);
  opacity: 0.85;
  text-align: center;
  font-size: 0.85rem;
  width: 56px;
}

.record-table .agency {
  font-family: var(--font-heading);
  font-weight: 600;
  color: var(--emerald-bright);
}
.record-table .oc { color: var(--text-soft); font-style: italic; }

.record-table td.col-actions {
  white-space: nowrap;
  text-align: right;
}

.empty-row td {
  text-align: center;
  font-style: italic;
  color: var(--text-soft);
  opacity: 0.75;
  padding: 22px 18px;
}

/* ===================================================================
   ADMIN PANEL / FORM
=================================================================== */

.admin-panel { margin-bottom: 90px; }

.admin-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
  text-align: left;
  max-width: 420px;
  margin: 0 auto;
}

.admin-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: var(--font-heading);
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-soft);
}

.admin-form input,
.admin-form select {
  font-family: var(--font-body);
  font-size: 1rem;
  background: #08090a;
  border: 1px solid var(--border-hair);
  color: var(--text-main);
  padding: 10px 12px;
  border-radius: 2px;
  outline: none;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}
.admin-form input:focus,
.admin-form select:focus {
  border-color: var(--emerald);
  box-shadow: 0 0 0 3px rgba(31,143,82,0.2);
}

/* ===================================================================
   FOOTER
=================================================================== */

.site-footer {
  text-align: center;
  padding: 50px 20px 70px;
  position: relative;
  overflow: hidden;
}

.site-footer::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: var(--diaper-pattern);
  background-size: var(--diaper-size4);
  background-position: var(--diaper-pos4);
  -webkit-mask-image: radial-gradient(ellipse 55% 100% at 50% 50%, black 0%, transparent 80%);
  mask-image: radial-gradient(ellipse 55% 100% at 50% 50%, black 0%, transparent 80%);
}

.site-footer > *:not(.battlement) { position: relative; z-index: 1; }

.footer-glow {
  font-family: var(--font-display);
  font-size: 1.1rem;
  letter-spacing: 0.3em;
  color: var(--emerald-bright);
  text-shadow: 0 0 16px rgba(63,224,138,0.6), 0 0 34px rgba(31,143,82,0.35);
  animation: pulse-glow 3.5s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%, 100% { opacity: 0.85; }
  50%      { opacity: 1; text-shadow: 0 0 22px rgba(63,224,138,0.8), 0 0 46px rgba(31,143,82,0.5); }
}

/* ===================================================================
   LOGIN MODAL
=================================================================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(2,3,2,0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.35s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-box {
  background: linear-gradient(180deg, var(--panel) 0%, #060706 100%);
  border: 1px solid var(--emerald-dim);
  box-shadow: 0 0 40px rgba(31,143,82,0.25), 0 30px 80px rgba(0,0,0,0.6);
  border-radius: 4px;
  padding: 46px 32px 40px;
  width: 100%;
  max-width: 380px;
  position: relative;
  text-align: center;
  overflow: hidden;
}

.modal-box::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: var(--diaper-pattern);
  background-size: var(--diaper-size4);
  background-position: var(--diaper-pos4);
}

.modal-box > *:not(.battlement):not(.modal-close) { position: relative; z-index: 1; }

.modal-box .battlement.top { border-radius: 4px 4px 0 0; }

.modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  color: var(--text-soft);
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
}
.modal-close:hover { color: var(--emerald-bright); }

.modal-title {
  font-family: var(--font-heading);
  color: var(--text-main);
  font-weight: 600;
  letter-spacing: 0.05em;
  margin: 0;
}

#login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: left;
  margin-top: 10px;
}
#login-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: var(--font-heading);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-soft);
}
#login-form input {
  font-family: var(--font-body);
  font-size: 1rem;
  background: #08090a;
  border: 1px solid var(--border-hair);
  color: var(--text-main);
  padding: 10px 12px;
  border-radius: 2px;
  outline: none;
}
#login-form input:focus {
  border-color: var(--emerald);
  box-shadow: 0 0 0 3px rgba(31,143,82,0.2);
}

#edit-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: left;
  margin-top: 10px;
}
#edit-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: var(--font-heading);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-soft);
}
#edit-form input {
  font-family: var(--font-body);
  font-size: 1rem;
  background: #08090a;
  border: 1px solid var(--border-hair);
  color: var(--text-main);
  padding: 10px 12px;
  border-radius: 2px;
  outline: none;
  width: 100%;
}
#edit-form input:focus {
  border-color: var(--emerald);
  box-shadow: 0 0 0 3px rgba(31,143,82,0.2);
}

.login-error {
  color: #e8615f;
  font-size: 0.85rem;
  font-style: italic;
  margin: -6px 0 0;
}

.login-success {
  color: var(--emerald-bright);
  font-size: 0.85rem;
  font-style: italic;
  margin: -6px 0 0;
}

/* ===================================================================
   RESPONSIVE
=================================================================== */

@media (max-width: 720px) {
  .site-header { padding: 70px 16px 40px; }
  .section-frame { padding: 34px 20px; }
  main { padding: 0 16px 60px; }
  .intro-seal { width: 300px; height: 300px; }
  .frame-corner { width: 32px; height: 32px; }
  .battlement { height: 7px; background-size: 200% 100%; }
  .battlement { background-image: repeating-linear-gradient(90deg, var(--emerald) 0 10px, transparent 10px 20px); }
}

@media (max-width: 480px) {
  .record-table { font-size: 0.9rem; }
  .record-table thead th, .record-table td { padding: 10px 12px; }
  .footer-glow { font-size: 0.9rem; letter-spacing: 0.2em; }
}

/* Respect reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
