/* loggtus. { SOLVE } — visual system extracted from Brand Book Loggtus v1.0 */

@font-face {
  font-family: 'Mayak';
  src: url('../fonts/Mayak-Regular.otf') format('opentype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Mayak';
  src: url('../fonts/Mayak-Medium.otf') format('opentype');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Mayak';
  src: url('../fonts/Mayak-Bold.otf') format('opentype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Mayak Extended';
  src: url('../fonts/MayakExtended-Bold.otf') format('opentype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink: #0E0F0C;
  --ink2: #15170F;
  --panel: #1B1E16;
  --cream: #FFF9E9;
  --paper: #F6EFD9;
  --green: #164C38;
  --emerald: #1FB866;
  --orange: #FF7D15;
  --red: #E8412C;
  --muted: #9C9A8C;
  --line: rgba(255, 249, 233, .12);
  --line-strong: rgba(255, 249, 233, .22);

  --fd: 'Mayak', sans-serif;
  --fdx: 'Mayak Extended', sans-serif;
  --fw: 'Sora', sans-serif;
  --ft: 'Sora', sans-serif;
  --fm: 'JetBrains Mono', monospace;

  --notch: 10px;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  background: var(--ink);
  color: var(--cream);
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--ft);
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-x: hidden;
}

::selection { background: var(--orange); color: var(--ink); }

.bg-field {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(circle at 16% 22%, rgba(255,125,21,.10), transparent 42%),
    radial-gradient(circle at 84% 78%, rgba(31,184,102,.10), transparent 42%),
    linear-gradient(rgba(255,249,233,.035) 1px, transparent 1px) 0 0/46px 46px,
    linear-gradient(90deg, rgba(255,249,233,.035) 1px, transparent 1px) 0 0/46px 46px,
    var(--ink);
}

.chamfer {
  clip-path: polygon(var(--notch) 0, 100% 0, 100% calc(100% - var(--notch)), calc(100% - var(--notch)) 100%, 0 100%, 0 var(--notch));
}

/* ============ HEADER ============ */
.app-header {
  padding: 18px clamp(16px, 4vw, 40px) 0;
  border-bottom: 1px solid var(--line);
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 16px;
}

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

.brand-mark {
  flex: none;
  width: 20px;
  height: 20px;
  background: var(--orange);
  clip-path: polygon(6px 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%, 0 6px);
}

.brand-word {
  font-family: var(--fw);
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -.01em;
  text-transform: lowercase;
  white-space: nowrap;
}
.brand-word .dot { color: var(--orange); }

.brand-sep {
  color: var(--line-strong);
  font-weight: 300;
  font-size: 18px;
}

.brand-product {
  font-family: var(--fd);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: .01em;
  text-transform: uppercase;
  color: var(--cream);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-product .brace { color: var(--orange); margin: 0 2px; }

.header-actions {
  display: flex;
  gap: 8px;
  flex: none;
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--cream);
  cursor: pointer;
  clip-path: polygon(7px 0, 100% 0, 100% calc(100% - 7px), calc(100% - 7px) 100%, 0 100%, 0 7px);
  transition: border-color .15s, color .15s, background .15s;
}
.icon-btn:hover { border-color: var(--orange); color: var(--orange); background: rgba(255,125,21,.06); }
.icon-btn:active { transform: translateY(1px); }

.mode-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 14px;
  flex-wrap: wrap;
}

.mode-tabs {
  display: flex;
  gap: 2px;
  background: var(--ink2);
  border: 1px solid var(--line);
  padding: 3px;
  clip-path: polygon(7px 0, 100% 0, 100% calc(100% - 7px), calc(100% - 7px) 100%, 0 100%, 0 7px);
}

.mode-tab {
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: var(--fm);
  font-size: 12px;
  letter-spacing: .1em;
  text-transform: uppercase;
  padding: 8px 16px;
  cursor: pointer;
  transition: color .15s, background .15s;
}
.mode-tab.is-active {
  background: var(--orange);
  color: var(--ink);
  font-weight: 700;
}
.mode-tab:not(.is-active):hover { color: var(--cream); }

.puzzle-meta {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-family: var(--fm);
  font-size: 12px;
  letter-spacing: .1em;
  color: var(--muted);
  text-transform: uppercase;
}
.puzzle-id { color: var(--emerald); }

.target-strip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px 0 18px;
}
.target-strip[hidden] { display: none; }
.target-label {
  font-family: var(--fm);
  font-size: 12px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--muted);
}
.target-value {
  font-family: var(--fd);
  font-weight: 700;
  font-size: 28px;
  color: var(--orange);
  border: 1.5px solid var(--orange);
  padding: 2px 16px;
  clip-path: polygon(7px 0, 100% 0, 100% calc(100% - 7px), calc(100% - 7px) 100%, 0 100%, 0 7px);
}

/* ============ MAIN / BOARD ============ */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 20px clamp(12px, 4vw, 40px) 12px;
  width: 100%;
  max-width: 620px;
  margin: 0 auto;
}

.board-wrap { width: 100%; display: flex; justify-content: center; }

.board {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  max-width: 480px;
}

.board-row {
  display: grid;
  grid-auto-flow: column;
  gap: 6px;
}

.tile {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--fm);
  font-weight: 700;
  font-size: clamp(16px, 5.2vw, 26px);
  color: var(--cream);
  background: var(--panel);
  border: 2px solid var(--line);
  clip-path: polygon(6px 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%, 0 6px);
  transition: transform .12s, border-color .12s, background .35s, color .35s;
  user-select: none;
}

.tile.is-filled { border-color: var(--line-strong); transform: scale(1.03); }
.tile.is-correct { background: var(--emerald); border-color: var(--emerald); color: var(--ink); }
.tile.is-present { background: var(--orange); border-color: var(--orange); color: var(--ink); }
.tile.is-absent  { background: var(--panel); border-color: transparent; color: var(--muted); }

.tile[role="button"] { cursor: pointer; }
.tile.is-selected {
  border-color: var(--orange);
  box-shadow: 0 0 0 2px rgba(255,125,21,.35);
}

.tile.flip {
  animation: tileFlip .45s ease forwards;
}
@keyframes tileFlip {
  0% { transform: rotateX(0); }
  50% { transform: rotateX(90deg); }
  51% { transform: rotateX(90deg); }
  100% { transform: rotateX(0); }
}

.board-row.shake { animation: rowShake .32s; }
@keyframes rowShake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-7px); }
  40%, 60% { transform: translateX(7px); }
}

.hint-line {
  font-family: var(--fm);
  font-size: 12px;
  letter-spacing: .04em;
  color: var(--muted);
  text-align: center;
}
.hint-line strong { color: var(--cream); }

/* ============ KEYBOARD ============ */
.keyboard {
  display: flex;
  flex-direction: column;
  gap: 7px;
  width: 100%;
  max-width: 560px;
}

.kb-row {
  display: flex;
  gap: 6px;
  justify-content: center;
}

.kb-key {
  flex: 1;
  max-width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--cream);
  font-family: var(--fm);
  font-weight: 600;
  font-size: 16px;
  cursor: pointer;
  clip-path: polygon(6px 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%, 0 6px);
  transition: background .15s, border-color .15s, transform .08s;
}
.kb-key:active { transform: translateY(1px) scale(.96); }
.kb-key:hover { border-color: var(--line-strong); }

.kb-key.wide { max-width: 84px; font-family: var(--fm); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; }

.kb-key.is-correct { background: var(--emerald); border-color: var(--emerald); color: var(--ink); }
.kb-key.is-present { background: var(--orange); border-color: var(--orange); color: var(--ink); }
.kb-key.is-absent  { background: var(--ink2); border-color: transparent; color: #4a4a40; }

/* ============ TOAST ============ */
.toast-region {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}

.toast {
  font-family: var(--fm);
  font-size: 12.5px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ink);
  background: var(--cream);
  border-left: 4px solid var(--red);
  padding: 10px 16px;
  box-shadow: 0 8px 24px rgba(0,0,0,.35);
  animation: toastIn .18s ease, toastOut .25s ease 1.6s forwards;
}
.toast.is-good { border-left-color: var(--emerald); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-8px); } }

/* ============ FOOTER ============ */
.app-footer {
  text-align: center;
  padding: 18px 16px 26px;
  font-family: var(--fm);
  font-size: 11px;
  letter-spacing: .06em;
  color: var(--muted);
}
.app-footer .dot { color: var(--orange); }

/* ============ MODALS ============ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 600;
  background: rgba(14,15,12,.72);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay[hidden] { display: none; }

.modal {
  --notch: 20px;
  position: relative;
  width: 100%;
  max-width: 440px;
  max-height: 86vh;
  overflow-y: auto;
  background: var(--cream);
  color: var(--ink);
  padding: 40px 32px 32px;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: none;
  border: none;
  font-size: 26px;
  line-height: 1;
  color: var(--ink);
  cursor: pointer;
  opacity: .55;
}
.modal-close:hover { opacity: 1; }

.modal-eyebrow {
  font-family: var(--fm);
  font-size: 11px;
  letter-spacing: .24em;
  text-transform: uppercase;
  color: var(--green);
  margin-bottom: 8px;
}

.modal-title {
  font-family: var(--fd);
  font-weight: 700;
  font-size: clamp(22px, 5vw, 28px);
  line-height: 1.08;
  text-transform: uppercase;
  margin-bottom: 16px;
}

.modal-text {
  font-size: 14.5px;
  line-height: 1.6;
  color: #3a3a30;
  margin-bottom: 12px;
}
.modal-text code, code.mono-example {
  font-family: var(--fm);
  background: rgba(14,15,12,.08);
  padding: 2px 6px;
  font-size: 13px;
  color: var(--ink);
}
.modal-rule { font-style: normal; border-left: 3px solid var(--orange); padding-left: 12px; }

.modal-divider {
  height: 1px;
  background: rgba(14,15,12,.14);
  margin: 22px 0;
}
.modal-divider[hidden] { display: none; }

.legend { display: flex; flex-direction: column; gap: 14px; margin: 18px 0 4px; }
.legend-row { display: flex; align-items: center; gap: 14px; }
.legend-row p { font-size: 14px; color: #3a3a30; margin: 0; }

.mini-tile {
  flex: none;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--fm);
  font-weight: 700;
  font-size: 17px;
  color: var(--cream);
  clip-path: polygon(6px 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%, 0 6px);
}
.mini-tile.is-correct { background: var(--emerald); }
.mini-tile.is-present { background: var(--orange); }
.mini-tile.is-absent { background: var(--panel); color: var(--muted); }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: rgba(14,15,12,.14);
  border: 1px solid rgba(14,15,12,.14);
  margin-top: 8px;
}
.stat-cell {
  background: var(--cream);
  padding: 14px 6px;
  text-align: center;
}
.stat-num {
  font-family: var(--fd);
  font-weight: 700;
  font-size: 24px;
  display: block;
}
.stat-label {
  font-family: var(--fm);
  font-size: 9.5px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: #6b6a5e;
  display: block;
  margin-top: 4px;
}

.dist-chart { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.dist-row { display: flex; align-items: center; gap: 8px; }
.dist-idx { font-family: var(--fm); font-size: 12px; width: 12px; color: #6b6a5e; }
.dist-bar-track { flex: 1; background: rgba(14,15,12,.06); height: 22px; }
.dist-bar {
  height: 100%;
  background: var(--green);
  color: var(--cream);
  font-family: var(--fm);
  font-size: 11.5px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 8px;
  min-width: 22px;
  transition: width .4s ease;
}
.dist-bar.is-current { background: var(--orange); color: var(--ink); font-weight: 700; }

.btn-primary {
  width: 100%;
  margin-top: 18px;
  padding: 14px 20px;
  background: var(--orange);
  color: var(--ink);
  border: none;
  font-family: var(--fd);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: .02em;
  text-transform: uppercase;
  cursor: pointer;
  clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
  transition: background .15s, transform .08s;
}
.btn-primary:hover { background: #ff8f36; }
.btn-primary:active { transform: translateY(1px); }
.btn-primary.is-copied { background: var(--emerald); }

.next-puzzle {
  margin-top: 14px;
  text-align: center;
  font-family: var(--fm);
  font-size: 12px;
  letter-spacing: .06em;
  color: #6b6a5e;
  text-transform: uppercase;
}

.result-grid { display: flex; flex-direction: column; gap: 4px; align-items: center; margin: 18px 0 4px; font-size: 22px; line-height: 1; }

@media (max-width: 420px) {
  .brand-sep, .brand-product { display: none; }
  .kb-key { height: 46px; font-size: 14px; }
  .kb-key.wide { font-size: 9.5px; }
}

/* Accessible visually-hidden helper (for SEO/AIEO H1 and semantic text) */
.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}
