/* ============================================================
   COMPONENTS: Archive Terminal (Classified Dossier)
   Source: Experiment9.html
   - Includes reset, base background, all UI components
   - Keeps your system "dumb HTML" compatible
============================================================ */

/* BASE RESET & TEXTURE */
html, body { height: 100%; }

body{
  margin: 0;
  padding: 40px 20px;
  background-color: var(--wall);
  color: var(--ink);
  font-family: var(--font-body);
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;

  background-image:
    linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 20px 20px;

  scroll-behavior: smooth;
}

/* Site shell helpers */
.site-header { margin: 0 0 18px; }
.site-header__inner{ display:flex; align-items:flex-end; justify-content:space-between; }
.site-brand__title{
  font-family: var(--font-label);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.5px;
  text-transform: uppercase;
  color: var(--ink);
}
.site-brand__subtitle{
  font-family: var(--font-data);
  font-size: 12px;
  opacity: 0.7;
}
.site-main{ display:block; }

/* COMMAND RAIL */
.command-rail{
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #dcdcdc;
  padding: 10px 16px;
  border: 1px solid #999;
  border-bottom: 4px solid #777;
  border-radius: 2px;
  margin-bottom: 40px;
  box-shadow: 0 10px 20px rgba(0,0,0,0.3);
  position: relative;
  z-index: 100;
}
.command-rail::before,
.command-rail::after{
  content: "⊗";
  color: #777;
  font-size: 14px;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
}
.command-rail::before{ left: 8px; }
.command-rail::after{ right: 8px; }

.rail-brand{
  font-family: var(--font-label);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.5px;
  text-transform: uppercase;
  color: var(--ink);
  margin-left: 20px;
  background: #fff;
  padding: 2px 8px;
  border: 1px solid #999;
  box-shadow: inset 1px 1px 2px rgba(0,0,0,0.1);
}

.rail-menu{
  display: flex;
  gap: 12px;
  margin-right: 20px;
  flex-wrap: wrap;            /* ✅ allows stacking */
  justify-content: flex-end;
}

.rail-btn{
  display: flex;
  align-items: center;
  padding: 6px 12px;
  background: #eee;
  border: 1px solid #999;
  border-bottom: 2px solid #777;
  font-family: var(--font-label);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  color: #555;
  text-decoration: none;
  transition: all 0.1s ease-out;
  border-radius: 2px;
  white-space: nowrap;
}
.rail-btn:hover{
  background: #fff;
  transform: translateY(-1px);
  color: #000;
}
.rail-btn:active{
  transform: translateY(1px);
  border-bottom-width: 1px;
}
.rail-btn.active{
  background: var(--stamp);
  color: #fff;
  border-color: #800000;
  transform: translateY(1px);
  border-bottom-width: 1px;
  pointer-events: none;
}

/* TERMINAL PLATE */
.terminal-plate{
  background: var(--plate);
  border: 1px solid #c0b49a;
  border-radius: 2px 12px 2px 2px;
  box-shadow: var(--shadow-plate);
  padding: 36px;
  position: relative;
  margin-bottom: 48px;
}
.terminal-plate::before{
  content: "CONFIDENTIAL // RIS";
  position: absolute;
  top: -24px;
  left: 0;
  background: var(--plate);
  padding: 4px 16px;
  height: 20px;
  border: 1px solid #c0b49a;
  border-bottom: none;
  border-radius: 4px 4px 0 0;
  font-family: var(--font-label);
  font-size: 10px;
  color: var(--stamp);
  letter-spacing: 1px;
  font-weight: 700;
}
.rivet{ display:none; }

/* TEXT + DIVIDERS */
.terminal-divider{
  height: 1px;
  background: rgba(0,0,0,0.18);
  margin: 26px 0;
}
.terminal-lead{
  font-family: var(--font-data);
  font-size: 13px;
  opacity: 0.85;
  margin: 10px 0 18px;
}

/* INPUTS */
input[type="text"], input[type="date"], select, textarea{
  background: var(--paper);
  border: 1px solid #ccc;
  border-radius: 0;
  padding: 12px 16px;
  font-family: var(--font-data);
  color: var(--ink);
  width: 100%;
  box-sizing: border-box;
  display: block;
  box-shadow: inset 2px 2px 4px rgba(0,0,0,0.05);
}
textarea{
  background-image: repeating-linear-gradient(
    transparent,
    transparent 27px,
    rgba(0,0,0,0.05) 28px
  );
  background-size: 100% 28px;
  line-height: 28px;
  resize: vertical;
}
input:focus, select:focus, textarea:focus{
  outline: none;
  background: #fff;
  border: 1px solid var(--accent);
  box-shadow: 0 0 0 3px rgba(44, 62, 80, 0.1);
}

/* BUTTONS */
.btn, .btn-key, .pill-toggle{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  background: #333;
  border: 2px solid #111;
  border-bottom: 4px solid #000;
  border-radius: 50px;
  font-family: var(--font-label);
  font-weight: 700;
  font-size: 12px;
  color: #fff;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: all 0.1s;
  text-decoration: none;
  box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}
.btn:hover, .btn-key:hover, .pill-toggle:hover{
  background: #444;
  transform: translateY(-1px);
}
.btn:active, .btn-key:active, .pill-toggle:active{
  transform: translateY(3px);
  border-bottom-width: 1px;
  box-shadow: none;
}
.btn.accent, .btn-key.primary, .pill-toggle.is-on{
  background: var(--stamp);
  border-color: #800000;
}
.btn.accent:hover, .btn-key.primary:hover, .pill-toggle.is-on:hover{
  background: #d13d3d;
}
.btn[disabled], .btn-key[disabled]{
  opacity: 0.5;
  cursor: not-allowed;
  background: #555;
}

/* MODULE GRID */
.module-grid{
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 24px;
  margin-top: 20px;
}
.module-card{
  background: var(--paper);
  border: 1px solid #bbb;
  padding: 24px;
  position: relative;
  box-shadow:
    1px 1px 3px rgba(0,0,0,0.1),
    0 10px 15px -5px rgba(0,0,0,0.1);
  transform: rotate(-0.5deg);
  transition: transform 0.2s;
}
.module-card:hover{
  transform: rotate(0deg) scale(1.02);
  z-index: 10;
  border-color: var(--accent);
}
.module-card::after{
  content: "";
  position: absolute;
  top: -10px;
  right: 20px;
  width: 10px;
  height: 30px;
  border: 2px solid #888;
  border-radius: 10px;
  background: transparent;
  z-index: 2;
}
.module-header{
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--ink);
}
.module-id{
  font-family: var(--font-data);
  font-size: 11px;
  font-weight: bold;
  color: var(--accent);
  display: block;
  margin-bottom: 4px;
}
.module-title{
  font-family: var(--font-label);
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  text-transform: uppercase;
}
.module-desc{
  font-family: var(--font-data);
  font-size: 12px;
  color: #444;
  line-height: 1.4;
  margin-bottom: 20px;
}
.module-stamp{
  position: absolute;
  bottom: 10px;
  right: 10px;
  border: 2px solid var(--stamp);
  padding: 4px 8px;
  color: var(--stamp);
  font-family: var(--font-label);
  font-weight: 900;
  font-size: 10px;
  transform: rotate(-10deg);
  opacity: 0.3;
  pointer-events: none;
}
.module-card:hover .module-stamp{ opacity: 1; }

/* UTILS */
h1, h2, h3, h4{
  font-family: var(--font-label);
  color: var(--ink);
  margin-top: 0;
  text-transform: uppercase;
  letter-spacing: -0.02em;
}

/* =========================================================
   Index text animations (AUTHORITATIVE, wrap-safe)
========================================================= */

/* Typewriter line: wrap-safe, never overflows */
.typewriter-line{
  display: inline;
  font-family: var(--font-data, "Courier Prime", monospace);
  overflow: hidden;
  border-right: 2px solid rgba(0,0,0,0.55);

  white-space: normal;
  word-break: break-word;

  max-width: 0;
}

@keyframes tw-reveal {
  from { max-width: 0; }
  to   { max-width: 100%; }
}

@keyframes tw-caret {
  0%, 100% { border-right-color: rgba(0,0,0,0.1); }
  50%      { border-right-color: rgba(0,0,0,0.7); }
}

.typewriter-line.is-on{
  display: inline-block;
  max-width: 0;
  animation:
    tw-reveal var(--tw-speed, 1.1s) linear forwards,
    tw-caret 0.7s step-end infinite;
}

/* Stamp-in */
.stamp-in{
  opacity: 0;
  transform: translateY(6px) rotate(-0.3deg);
}

@keyframes stampIn {
  0%   { opacity: 0; transform: translateY(8px) rotate(-0.6deg) scale(0.995); }
  60%  { opacity: 1; transform: translateY(0) rotate(0deg) scale(1.01); }
  100% { opacity: 1; transform: translateY(0) rotate(0deg) scale(1); }
}

.stamp-in.is-on{
  animation: stampIn 420ms ease-out forwards;
}

@media (prefers-reduced-motion: reduce){
  .typewriter-line,
  .typewriter-line.is-on,
  .stamp-in,
  .stamp-in.is-on{
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
    border-right: none !important;
    max-width: none !important;
  }
}
