@charset "UTF-8";

/* =====================================================
   CTHULHU CHARACTER ARCHIVE — COMMON STYLESHEET
   共通デザイン基盤（超軽量テクスチャ・GPU負荷根絶版）
===================================================== */

/* =====================================================
   DESIGN TOKENS
===================================================== */
:root {
  --paper: #e8e4dc;
  --paper2: #f0ede7;

  --ink: #171717;
  --muted: #77736d;
  --line: #aaa49c;

  --red: #b71920;
  --red2: #d52a31;

  --black: #111111;
  --green: #38734f;

  --sheet: min(92vw, 1100px);

  --font-serif: "Noto Serif JP", serif;
  --font-title: "Cinzel", serif;
  --font-mono: "IBM Plex Mono", monospace;
}

/* =====================================================
   RESET
===================================================== */
* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  padding: 36px 20px 100px;
  background:
    radial-gradient(circle at 15% 10%, rgba(255, 255, 255, 0.05), transparent 25%),
    radial-gradient(circle at 85% 90%, rgba(255, 255, 255, 0.03), transparent 28%),
    #101010;
  color: var(--ink);
  font-family: var(--font-serif);
  line-height: 1.6;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a,
input,
select,
textarea {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

input,
textarea,
select {
  color: var(--ink);
}

input::placeholder,
textarea::placeholder {
  color: #aaa;
  font-size: 0.9em;
  letter-spacing: 0.05em;
}

img {
  max-width: 100%;
}

/* =====================================================
   GLOBAL TEXT SELECTION
===================================================== */
::selection {
  background: rgba(183, 25, 32, 0.18);
  color: var(--ink);
}

/* =====================================================
   ARCHIVE SHEET
===================================================== */
.archive-shell {
  width: var(--sheet);
  margin: auto;
}

.sheet {
  min-height: 1400px;
  position: relative;
  overflow: clip;
  padding: 26px 48px 28px;
  background: var(--paper);
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.55);
}

/* 
  紙の微細テクスチャ（超軽量SVGノイズ）
  ※全画面fixedを廃止し、紙面内のみで合成負荷ゼロで描画
*/
.sheet::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
  background-repeat: repeat;
}

/* 内側罫線 */
.sheet::after {
  content: "";
  position: absolute;
  inset: 14px;
  pointer-events: none;
  border: 1px solid rgba(0, 0, 0, 0.12);
}

/* =====================================================
   CORNERS
===================================================== */
.corner {
  width: 25px;
  height: 25px;
  position: absolute;
  z-index: 2;
  border-color: var(--red);
  opacity: 0.85;
  pointer-events: none;
}

.corner.tl {
  left: 27px;
  top: 27px;
  border-left: 2px solid;
  border-top: 2px solid;
}

.corner.tr {
  right: 27px;
  top: 27px;
  border-right: 2px solid;
  border-top: 2px solid;
}

.corner.bl {
  left: 27px;
  bottom: 27px;
  border-left: 2px solid;
  border-bottom: 2px solid;
}

.corner.br {
  right: 27px;
  bottom: 27px;
  border-right: 2px solid;
  border-bottom: 2px solid;
}

.content {
  position: relative;
  z-index: 2;
}

/* =====================================================
   HEADER
===================================================== */
header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 16px;
}

.brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 15px;
}

/* ARCHIVE MARK */
.mark {
  width: 34px;
  height: 34px;
  position: relative;
  flex: none;
  border: 1px solid var(--ink);
  transform: rotate(45deg);
}

.mark::before,
.mark::after {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px solid var(--red);
}

.mark::after {
  inset: 14px;
  border-color: var(--ink);
}

/* BRAND TYPOGRAPHY */
.title-en {
  flex: none;
  font: 600 18px/1.05 var(--font-title);
  letter-spacing: 0.14em;
}

.title-jp {
  margin-left: 3px;
  padding-left: 16px;
  border-left: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.65;
  letter-spacing: 0.18em;
}

/* CASE META */
.case-meta {
  flex: none;
  text-align: right;
}

.case-no {
  font: 600 17px var(--font-mono);
  letter-spacing: 0.08em;
}

.case-label {
  margin-top: 4px;
  color: var(--muted);
  font: 10px var(--font-mono);
  letter-spacing: 0.18em;
}

/* PAGE INDICATOR */
.pages {
  display: flex;
  justify-content: flex-end;
  gap: 7px;
  margin-top: 8px;
}

.pages span {
  width: 18px;
  height: 18px;
  border: 1px solid #aaa;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #777;
  font: 9px var(--font-mono);
}

.pages span.active {
  border-color: var(--red);
  color: var(--red);
}

/* =====================================================
   RADAR (2層レーダー)
===================================================== */
.radar-panel {
  position: relative;
  display: flex;
  justify-content: center;
}

.radar {
  width: min(100%, 430px);
  aspect-ratio: 1;
  position: relative;
}

.radar svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.radar .grid {
  fill: none;
  stroke: #aaa;
  stroke-width: 0.65;
}

.radar .axis {
  stroke: #aaa;
  stroke-width: 0.55;
}

.radar-current-polygon {
  fill: rgba(23, 23, 23, 0.82);
  stroke: var(--red);
  stroke-width: 2;
  transition: all 0.25s ease;
}

.radar-base-polygon {
  fill: none;
  stroke: #8a857d;
  stroke-width: 1.3;
  stroke-dasharray: 3 3;
  pointer-events: none;
  transition: all 0.25s ease;
}

.radar .node {
  fill: var(--red);
  transition: all 0.25s ease;
}

.radar .base-node {
  fill: #8a857d;
  opacity: 0.85;
}

.radar .stat {
  text-anchor: middle;
  fill: #222;
  font: 500 12px var(--font-mono);
  letter-spacing: 0.08em;
}

.radar .val {
  text-anchor: middle;
  fill: #111;
  font: 600 13px var(--font-mono);
}

.radar .diff-val {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
}

.radar .diff-val.plus {
  fill: var(--red);
}

.radar .diff-val.minus {
  fill: #4b6a82;
  font-style: italic;
}

.radar-caption {
  margin-top: -4px;
  color: #777;
  text-align: center;
  font: 9px var(--font-mono);
  letter-spacing: 0.2em;
}

/* =====================================================
   DIVIDER
===================================================== */
.divider {
  height: 1px;
  position: relative;
  margin: 30px 0 28px;
  background: var(--line);
}

.divider::before {
  content: "ARCHIVE RECORD";
  position: absolute;
  left: 0;
  top: -17px;
  padding-right: 10px;
  background: var(--paper);
  color: #888;
  font: 9px var(--font-mono);
  letter-spacing: 0.2em;
}

/* CONFIDENTIAL DIVIDER */
.confidential-divider {
  height: 18px;
  position: relative;
  margin: 34px 0 30px;
  border-top: 4px solid #171717;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.confidential-divider::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -1px;
  border-top: 1px solid rgba(183, 25, 32, 0.45);
  transform: translateY(5px);
}

.confidential-divider span {
  position: relative;
  z-index: 1;
  margin-top: -11px;
  padding: 2px 16px 3px;
  background: var(--paper);
  color: #171717;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.16em;
}

/* =====================================================
   SECTION TITLE
===================================================== */
.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0.16em;
}

.section-title::before {
  content: "";
  width: 4px;
  height: 17px;
  flex: none;
  background: var(--red);
}

.section-title small {
  color: #888;
  font: 400 9px var(--font-mono);
  letter-spacing: 0.12em;
}

/* =====================================================
   CARD
===================================================== */
.card {
  position: relative;
  padding: 14px 15px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.24);
}

.card::before {
  content: "";
  width: 22px;
  height: 1px;
  position: absolute;
  left: 0;
  top: 0;
  background: var(--red);
}

.card-title {
  margin-bottom: 9px;
  color: #555;
  font: 600 10px var(--font-mono);
  letter-spacing: 0.18em;
}

.dark-card {
  border-color: #141414;
  background: #141414;
  color: #eee;
}

.dark-card .card-title {
  color: #aaa;
}

.compact-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.editable-surface {
  border-radius: 0;
}

input.editable-surface,
textarea.editable-surface,
select.editable-surface {
  outline: none;
}

/* =====================================================
   BUTTON
===================================================== */
.btn {
  min-height: 32px;
  box-sizing: border-box;
  padding: 7px 12px;
  border: 1px solid #555;
  border-radius: 0;
  background: transparent;
  color: #222;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  text-align: center;
  font: 10px var(--font-mono);
  letter-spacing: 0.1em;
  transition: background 0.2s, color 0.2s, border-color 0.2s, opacity 0.2s;
}

.btn:hover {
  background: #222;
  color: #fff;
}

.btn.primary {
  border-color: #111;
  background: #111;
  color: #fff;
}

.btn.primary:hover {
  border-color: var(--red);
  background: var(--red);
}

.btn.ghost {
  border-color: var(--line);
  background: transparent;
}

.btn.ghost:hover {
  border-color: #222;
  background: #222;
  color: #fff;
}

.btn.danger:hover {
  border-color: var(--red);
  background: var(--red);
  color: #fff;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.btn.primary:disabled {
  border-color: #555;
  background: #555;
}

.icon-btn {
  min-height: 28px;
  padding: 5px 7px;
  border: 1px solid #aaa;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font: 10px var(--font-mono);
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.icon-btn:hover {
  border-color: #111;
  background: #111;
  color: #fff;
}

/* =====================================================
   TOAST
===================================================== */
.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 4000;
  max-width: min(420px, calc(100vw - 40px));
  padding: 11px 14px;
  border-left: 2px solid var(--red);
  background: #111;
  color: #fff;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  box-shadow: 0 10px 35px rgba(0, 0, 0, 0.35);
  font: 10px var(--font-mono);
  letter-spacing: 0.1em;
  line-height: 1.6;
  transition: opacity 0.2s, transform 0.2s;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* =====================================================
   FOOTER
===================================================== */
footer,
.footer-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-top: 34px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
  color: #777;
  font: 9px var(--font-mono);
  letter-spacing: 0.14em;
}

.footer-buttons {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

/* =====================================================
   FOCUS
===================================================== */
.btn:focus-visible,
.icon-btn:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 1px solid var(--red);
  outline-offset: 2px;
}

input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: none;
}

/* =====================================================
   SCROLLBAR
===================================================== */
* {
  scrollbar-width: thin;
  scrollbar-color: #8f8a83 transparent;
}

*::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background: #8f8a83;
}

*::-webkit-scrollbar-thumb:hover {
  background: #6f6a63;
}

/* =====================================================
   UTILITIES
===================================================== */
[hidden] {
  display: none !important;
}

.sr-only {
  width: 1px !important;
  height: 1px !important;
  position: absolute !important;
  overflow: hidden !important;
  margin: -1px !important;
  padding: 0 !important;
  border: 0 !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
}

/* =====================================================
   RESPONSIVE
===================================================== */
@media (max-width: 900px) {
  .sheet {
    padding: 26px 34px 28px;
  }
  .corner.tl,
  .corner.bl {
    left: 20px;
  }
  .corner.tr,
  .corner.br {
    right: 20px;
  }
}

@media (max-width: 700px) {
  body {
    padding: 12px 0 60px;
  }

  .archive-shell {
    width: min(100%, 100vw);
  }

  .sheet {
    min-height: auto;
    padding: 22px 18px 26px;
  }

  .sheet::after {
    inset: 8px;
  }

  .corner {
    width: 18px;
    height: 18px;
  }
  .corner.tl { left: 12px; top: 12px; }
  .corner.tr { right: 12px; top: 12px; }
  .corner.bl { left: 12px; bottom: 12px; }
  .corner.br { right: 12px; bottom: 12px; }

  header { gap: 12px; }
  .brand { gap: 10px; }
  .mark { width: 29px; height: 29px; }
  .mark::before { inset: 7px; }
  .mark::after { inset: 12px; }

  .title-en { font-size: 14px; letter-spacing: 0.11em; }
  .title-jp { display: none; }
  .case-no { font-size: 13px; }
  .case-label { max-width: 150px; font-size: 8px; line-height: 1.4; }

  .pages { gap: 4px; }
  .pages span { width: 16px; height: 16px; font-size: 8px; }

  .section-title { flex-wrap: wrap; gap: 7px; font-size: 13px; }
  .section-title small { font-size: 8px; }

  .compact-row { grid-template-columns: 1fr; }

  footer,
  .footer-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    text-align: center;
  }

  .footer-buttons {
    width: 100%;
    justify-content: center;
  }

  .footer-buttons .btn {
    flex: 1;
  }
}

@media (max-width: 430px) {
  .sheet {
    padding: 20px 14px 24px;
  }

  header { align-items: flex-start; }
  .mark { width: 26px; height: 26px; }
  .title-en { font-size: 12px; }
  .case-meta { max-width: 115px; }
  .case-label { font-size: 7px; }

  .footer-buttons { flex-direction: column; }
  .footer-buttons .btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .btn,
  .icon-btn,
  .toast,
  .radar-current-polygon,
  .radar-base-polygon,
  .radar .node {
    transition: none !important;
  }
}
