/* ============================================================
   NADSAT TRANSLATOR — 時計じかけのオレンジ風デザイン
   黒 × オレンジ × 白 / 1971年映画ポスターのタイポグラフィを意識
   ============================================================ */

:root {
  --orange: #ff6a00;
  --orange-bright: #ff8c1a;
  --black: #0a0a0a;
  --white: #f5f2ec;
  --panel: #141414;
  --line: #2a2a2a;
  --jp-font: "Noto Sans JP", sans-serif;
  --display-font: "Archivo Black", "Noto Sans JP", sans-serif;
  --latin-font: "Oswald", "Noto Sans JP", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--black);
  color: var(--white);
  font-family: var(--jp-font);
  min-height: 100vh;
  /* ポスター風: 斜めのオレンジ光線 */
  background-image:
    repeating-linear-gradient(
      115deg,
      transparent 0 120px,
      rgba(255, 106, 0, 0.04) 120px 240px
    );
}

/* ---------- ヒーロー ---------- */

.hero {
  display: flex;
  justify-content: center;
  padding: 3rem 1rem 0;
}

.hero-triangle {
  position: relative;
  width: min(680px, 94vw);
  padding: 2.5rem 2rem 3rem;
  text-align: center;
  background: var(--orange);
  color: var(--black);
  /* ポスターの「A」型三角形 */
  clip-path: polygon(50% 0%, 100% 88%, 100% 100%, 0% 100%, 0% 88%);
  box-shadow: 0 0 80px rgba(255, 106, 0, 0.35);
}

.hero-eye {
  width: 130px;
  margin-top: 1.2rem;
  filter: drop-shadow(0 4px 0 rgba(0, 0, 0, 0.25));
}

.hero-eye .pupil { animation: look 7s ease-in-out infinite; }
@keyframes look {
  0%, 55%, 100% { transform: translateX(0); }
  62%, 75% { transform: translateX(9px); }
  82%, 92% { transform: translateX(-9px); }
}

.hero-title { line-height: 1.05; margin-top: 0.8rem; }
.hero-title .jp {
  display: block;
  font-family: var(--jp-font);
  font-weight: 900;
  font-size: clamp(1.7rem, 5.4vw, 2.9rem);
  letter-spacing: 0.04em;
}
.hero-title .en {
  display: block;
  font-family: var(--display-font);
  font-size: clamp(0.9rem, 2.6vw, 1.35rem);
  letter-spacing: 0.42em;
  margin-top: 0.45rem;
  text-indent: 0.42em;
}

.hero-sub {
  margin-top: 0.7rem;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.2em;
}

/* ---------- タブ ---------- */

main { max-width: 1060px; margin: 0 auto; padding: 2.2rem 1rem 3rem; }

.tabs {
  display: flex;
  gap: 0.5rem;
  border-bottom: 3px solid var(--orange);
  margin-bottom: 1.6rem;
}

.tab {
  font-family: var(--jp-font);
  font-weight: 900;
  font-size: 1rem;
  letter-spacing: 0.12em;
  color: var(--white);
  background: transparent;
  border: none;
  padding: 0.7rem 1.4rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.tab:hover { color: var(--orange-bright); }
.tab.active {
  background: var(--orange);
  color: var(--black);
}

.panel { display: none; }
.panel.active { display: block; }

/* ---------- 翻訳パネル ---------- */

.io-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 1rem;
  align-items: stretch;
}
@media (max-width: 800px) {
  .io-grid { grid-template-columns: 1fr; }
  .io-arrow { transform: rotate(90deg); }
}

.io-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 4px solid var(--orange);
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
}

.io-label {
  font-weight: 900;
  letter-spacing: 0.1em;
  font-size: 0.95rem;
}
.io-tag {
  font-family: var(--latin-font);
  font-size: 0.68rem;
  letter-spacing: 0.3em;
  color: var(--orange);
  margin-left: 0.5rem;
  vertical-align: 2px;
}
.io-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

textarea {
  margin-top: 0.8rem;
  flex: 1;
  min-height: 200px;
  resize: vertical;
  background: var(--black);
  color: var(--white);
  border: 1px solid var(--line);
  padding: 0.9rem;
  font-family: var(--jp-font);
  font-size: 1.05rem;
  line-height: 1.9;
}
textarea:focus {
  outline: 2px solid var(--orange);
  outline-offset: -1px;
}

.io-arrow {
  align-self: center;
  color: var(--orange);
  font-size: 1.6rem;
  text-shadow: 0 0 18px rgba(255, 106, 0, 0.7);
}

.output {
  margin-top: 0.8rem;
  flex: 1;
  min-height: 200px;
  background: var(--black);
  border: 1px solid var(--line);
  padding: 0.9rem;
  font-size: 1.05rem;
  line-height: 1.9;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-y: auto;
}
.output .placeholder { color: #555; }

.output .nadsat {
  color: var(--orange-bright);
  font-weight: 700;
  border-bottom: 1px dashed rgba(255, 140, 26, 0.5);
  cursor: help;
}

.stats {
  margin-top: 0.6rem;
  font-size: 0.8rem;
  color: #888;
  letter-spacing: 0.05em;
  min-height: 1.2em;
}

/* コピーボタン */
.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
  font-family: var(--jp-font);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--black);
  background: var(--orange);
  border: none;
  padding: 0.45rem 1rem;
  cursor: pointer;
  letter-spacing: 0.08em;
  transition: background 0.15s, transform 0.1s;
}
.copy-btn:hover { background: var(--orange-bright); }
.copy-btn:active { transform: scale(0.96); }

/* 例文 */
.examples {
  margin-top: 0.7rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}
.examples-label { font-size: 0.78rem; color: #888; }
.example-btn {
  font-family: var(--jp-font);
  font-size: 0.78rem;
  color: var(--white);
  background: transparent;
  border: 1px solid var(--line);
  padding: 0.3rem 0.6rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.example-btn:hover { border-color: var(--orange); color: var(--orange-bright); }

.hint {
  margin-top: 1.2rem;
  font-size: 0.82rem;
  color: #999;
  line-height: 1.8;
  border-left: 3px solid var(--orange);
  padding-left: 0.8rem;
}

/* ---------- 辞書パネル ---------- */

.dict-head {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1rem;
}

#dict-search {
  flex: 1;
  max-width: 420px;
  background: var(--panel);
  color: var(--white);
  border: 1px solid var(--line);
  border-left: 4px solid var(--orange);
  padding: 0.65rem 0.9rem;
  font-family: var(--jp-font);
  font-size: 0.95rem;
}
#dict-search:focus { outline: 2px solid var(--orange); outline-offset: -1px; }

.dict-count { font-size: 0.85rem; color: #888; }

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
}

.dict-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
.dict-table th {
  font-family: var(--jp-font);
  font-weight: 900;
  text-align: left;
  letter-spacing: 0.1em;
  background: var(--orange);
  color: var(--black);
  padding: 0.7rem 0.9rem;
  position: sticky;
  top: 0;
}
.dict-table td {
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  line-height: 1.6;
}
.dict-table tbody tr:nth-child(odd) { background: #101010; }
.dict-table tbody tr:hover { background: rgba(255, 106, 0, 0.08); }
.dict-table .nadsat-word {
  font-family: var(--latin-font);
  font-weight: 600;
  color: var(--orange-bright);
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.dict-table .kana { font-weight: 700; }
.dict-table .origin { color: #999; font-size: 0.85rem; }

/* ---------- フッター / トースト ---------- */

footer {
  border-top: 3px solid var(--orange);
  padding: 1.6rem 1rem 2.4rem;
  text-align: center;
  font-size: 0.78rem;
  color: #888;
  line-height: 1.9;
}
.footer-quote {
  font-family: var(--latin-font);
  letter-spacing: 0.25em;
  color: var(--orange);
  margin-top: 0.5rem;
  font-size: 0.85rem;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 2rem;
  transform: translate(-50%, 20px);
  background: var(--orange);
  color: var(--black);
  font-weight: 900;
  letter-spacing: 0.08em;
  padding: 0.8rem 1.6rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  box-shadow: 0 6px 30px rgba(255, 106, 0, 0.4);
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- モバイル ---------- */

@media (max-width: 600px) {
  .hero { padding: 1.6rem 0.6rem 0; }
  .hero-triangle { padding: 2.1rem 1rem 1.6rem; }
  .hero-eye { width: 84px; margin-top: 0.6rem; }
  /* 三角形の斜辺にタイトルが切られないよう小さめに */
  .hero-title .jp { font-size: 1.42rem; letter-spacing: 0.02em; }
  .hero-title .en { font-size: 0.72rem; letter-spacing: 0.3em; text-indent: 0.3em; }
  .hero-sub { font-size: 0.78rem; letter-spacing: 0.12em; }

  main { padding: 1.4rem 0.7rem 2rem; }

  .tabs { gap: 0.3rem; }
  .tab {
    flex: 1;
    padding: 0.65rem 0.4rem;
    font-size: 0.9rem;
    letter-spacing: 0.05em;
  }

  .io-grid { gap: 0.7rem; }
  .io-box { padding: 0.85rem; }
  textarea, .output { min-height: 140px; font-size: 1rem; line-height: 1.8; }
  .io-arrow { font-size: 1.2rem; }

  .examples { gap: 0.35rem; }
  .example-btn {
    font-size: 0.75rem;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .hint { font-size: 0.78rem; }

  .dict-head { flex-direction: column; align-items: stretch; gap: 0.5rem; }
  #dict-search { max-width: none; }
  .dict-count { text-align: right; }
  .dict-table { font-size: 0.82rem; min-width: 560px; } /* 横スクロールで全列閲覧 */
  .dict-table th, .dict-table td { padding: 0.5rem 0.6rem; }

  .toast {
    width: calc(100% - 2rem);
    text-align: center;
    bottom: 1rem;
    font-size: 0.9rem;
  }

  footer { font-size: 0.72rem; padding: 1.2rem 0.8rem 1.8rem; }
}

/* タッチ端末: 変換語はタップで説明を出す(ホバー不可のため) */
@media (hover: none) {
  .output .nadsat { cursor: pointer; }
}

.table-wrap { -webkit-overflow-scrolling: touch; }
