/* base.css — the newspaper look shared by every screen: stage scaling, paper, ink type, plate buttons,
   clipping panels, modals, seal stamps, toasts and subtitles. Screen-specific rules live in board.css / screens.css. */
:root {
  --ink: #1d1a17;
  --ink-soft: #3a352f;
  --paper: #e8e0cc;
  --paper-2: #ddd3bb;
  --paper-dark: #c9bea3;
  --crimson: #8e2a22;
  --crimson-bright: #b23a2c;
  --slate: #3d4247;
  --rule: #2a2622;
  --serif: "Songti TC", "Noto Serif TC", "Noto Serif CJK TC", "Hiragino Mincho ProN", "Yu Mincho", serif;
  --noise: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.12  0 0 0 0 0.1  0 0 0 0 0.08  0 0 0 0.22 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #111315; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
body { font-family: var(--serif); color: var(--ink); }
#bg {
  position: fixed; inset: 0;
  background: radial-gradient(ellipse at 50% 40%, #3a3f43 0%, #1b1e21 60%, #0d0f10 100%);
}
#stage {
  position: absolute; left: 50%; top: 50%; width: 396px; height: 704px;
  transform-origin: 50% 50%; overflow: hidden;
  background: var(--paper);
}
#layer-screen, #layer-modal { position: absolute; inset: 0; }
#layer-modal { pointer-events: none; }
#layer-modal > * { pointer-events: auto; }
#fx-canvas { position: absolute; left: 0; top: 0; width: 396px; height: 704px; pointer-events: none; z-index: 30; }
.hidden { display: none !important; }

/* paper surface: aged newsprint with grain and faint damp blotches */
.paper {
  background-color: var(--paper);
  background-image: var(--noise),
    radial-gradient(ellipse at 15% 20%, rgba(120, 100, 60, 0.10), transparent 45%),
    radial-gradient(ellipse at 85% 75%, rgba(90, 80, 60, 0.12), transparent 50%),
    linear-gradient(180deg, #ece5d2, #e0d7c0);
}
.rule { height: 0; border-top: 1px solid var(--rule); }
.rule-double { height: 4px; border-top: 2px solid var(--rule); border-bottom: 1px solid var(--rule); }
.headline { font-weight: 900; letter-spacing: 0.02em; line-height: 1.12; color: var(--ink); }
.kicker { font-size: 12px; letter-spacing: 0.18em; color: var(--ink-soft); }
.body-text { font-size: 15px; line-height: 1.65; color: var(--ink); text-align: justify; }
.small { font-size: 13px; color: var(--ink-soft); }

/* halftone photo treatment for newspaper pictures */
.halftone { position: relative; overflow: hidden; background: #cfc6b0; }
.halftone > img { width: 100%; height: 100%; object-fit: cover; display: block; filter: grayscale(1) contrast(1.15) brightness(1.02) sepia(0.18); }
.halftone::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: radial-gradient(rgba(20, 16, 12, 0.32) 32%, transparent 36%);
  background-size: 3px 3px; mix-blend-mode: multiply; opacity: 0.55;
}

/* plate buttons (ui-button 9-slice) */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; min-width: 44px; padding: 0 16px;
  font-family: inherit; font-size: 16px; font-weight: 700; letter-spacing: 0.06em;
  color: #efe7d2; text-shadow: 0 1px 0 #000, 0 0 2px #000;
  background: #201c18; border: 3px solid transparent;
  border-image: url("../assets/ui-button.webp") 22% / 10px stretch;
  border-image-outset: 0;
  cursor: pointer; transition: transform 0.12s ease, filter 0.12s ease;
}
.btn::before { content: ""; position: absolute; inset: 2px; background: #201c18; z-index: -1; }
.btn-primary { background: var(--crimson); color: #f7eedb; }
.btn-primary::before { background: var(--crimson); }
.btn:hover { filter: brightness(1.18); }
.btn.pressed { animation: press 0.22s ease-out; }
.btn.disabled, .btn:disabled { filter: grayscale(1) brightness(0.75); opacity: 0.6; cursor: default; }
.btn-icon { width: 24px; height: 24px; object-fit: contain; }
.btn-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
@keyframes press { 0% { transform: scale(1); } 35% { transform: scale(0.92, 0.9); } 70% { transform: scale(1.04); } 100% { transform: scale(1); } }

/* keyboard / gamepad focus */
body.kb-nav .nav.focus { outline: 3px solid var(--crimson-bright); outline-offset: 2px; filter: brightness(1.12); transform: scale(1.03); }

/* clipping panel (ui-panel 9-slice) */
.panel {
  position: relative; color: var(--ink);
  border: 14px solid transparent;
  border-image: url("../assets/ui-panel.webp") 10% / 14px stretch;
  background: #e9e1cd; background-clip: padding-box;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}
.panel-inner { padding: 8px; }

/* modal */
.modal-back {
  position: absolute; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  background: rgba(14, 14, 16, 0.58); backdrop-filter: blur(1.5px);
}
.modal-back.sheet { align-items: flex-end; }
.modal-panel { width: 352px; max-height: 640px; display: flex; flex-direction: column; }
.modal-title { font-size: 22px; font-weight: 900; text-align: center; margin: 4px 0 8px; }
.modal-actions { display: flex; gap: 10px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }
.modal-actions .btn { flex: 1 1 0; }

/* crimson seal stamp */
.seal {
  position: absolute; left: 50%; top: 50%; z-index: 5; pointer-events: none;
  display: flex; align-items: center; justify-content: center;
  border: 4px double var(--crimson-bright); border-radius: 10px; color: var(--crimson-bright);
  font-weight: 900; letter-spacing: 0.08em; background: rgba(178, 58, 44, 0.06);
  transform: translate(-50%, -50%) rotate(var(--rot, -12deg));
  animation: seal-slam 0.34s cubic-bezier(.2,1.6,.4,1) both; mix-blend-mode: multiply;
  text-shadow: 0 0 1px rgba(178, 58, 44, 0.6);
}
.seal span { display: block; text-align: center; line-height: 1.05; }
@keyframes seal-slam { 0% { transform: translate(-50%, -50%) rotate(var(--rot)) scale(2.6); opacity: 0; } 60% { opacity: 1; } 100% { transform: translate(-50%, -50%) rotate(var(--rot)) scale(1); opacity: 0.92; } }

.flash { position: absolute; inset: 0; z-index: 29; pointer-events: none; }

/* toast and subtitles */
.toast {
  position: absolute; left: 50%; top: 150px; z-index: 40; transform: translateX(-50%);
  max-width: 330px; padding: 8px 16px; font-size: 15px; font-weight: 700; text-align: center;
  color: #f1e9d4; background: rgba(24, 21, 18, 0.92); border-top: 2px solid var(--crimson); border-bottom: 2px solid var(--crimson);
  pointer-events: none;
}
.toast.show { animation: toast-in 0.28s cubic-bezier(.2,1.4,.4,1); }
@keyframes toast-in { from { transform: translate(-50%, -12px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
.subtitle {
  position: absolute; left: 16px; right: 16px; bottom: 96px; z-index: 45;
  padding: 10px 14px; font-size: 16px; line-height: 1.5; text-align: center; color: #f3ecd8;
  background: rgba(10, 10, 10, 0.72); border-left: 3px solid var(--crimson); text-shadow: 0 1px 2px #000;
  pointer-events: none;
}
