/* Loowit Intelligence — Sudoku Solver
   Brand system:
     Slate Blue   #3F5D73   (primary)
     Charcoal     #5E646B
     Warm Taupe   #A89F94
     Off White    #F3F1EC   (canvas/background)
     Accents (chart palette): Teal #2BA197, Green #4C9A50, Gold #CCB974,
                              Orange #D56A45, Red #CA4A4A, Azure #2E7DB9
   Type: Cinzel (≈ Trajan Pro) headlines · Montserrat (≈ Avenir) body/UI */

:root {
  --slate: #3F5D73;
  --slate-dark: #2c4253;
  --charcoal: #5E646B;
  --taupe: #A89F94;
  --offwhite: #F3F1EC;
  --teal: #2BA197;
  --green: #4C9A50;
  --gold: #CCB974;
  --orange: #D56A45;
  --red: #CA4A4A;
  --azure: #2E7DB9;

  --ink: #2a2f34;
  --line: rgba(63, 93, 115, 0.16);
  --shadow: 0 10px 40px rgba(44, 66, 83, 0.12);
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(63, 93, 115, 0.08), transparent),
    var(--offwhite);
  color: var(--ink);
  font-family: "Montserrat", -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---- Header ---- */
.site-header {
  text-align: center;
  padding: 28px 20px 8px;
}
.logo {
  height: 64px;
  width: auto;
}
.tagline {
  font-family: "Cinzel", Georgia, serif;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--charcoal);
  margin: 6px 0 0;
}

/* ---- Layout ---- */
.app {
  flex: 1;
  width: min(1100px, 94vw);
  margin: 18px auto 0;
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 24px;
  align-items: start;
}
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
}

/* ---- Video stage ---- */
.video-frame {
  position: relative;
  aspect-ratio: 4 / 3;
  background: #11161b;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
#video, #overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
#video { transform: scaleX(-1); }      /* mirror like a selfie cam */
#overlay { transform: scaleX(-1); }    /* keep overlay aligned with mirrored video */

.hint {
  text-align: center;
  color: var(--charcoal);
  font-size: 0.85rem;
  margin: 12px 4px 0;
}

.puzzle-link {
  text-align: center;
  font-size: 0.85rem;
  color: var(--charcoal);
  margin: 6px 4px 0;
}
.puzzle-link a {
  color: var(--teal);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.18s ease;
}
.puzzle-link a:hover { border-bottom-color: var(--teal); }

.is-hidden { display: none !important; }

/* ---- Frozen result view ---- */
/* The cached frame is drawn in true (un-mirrored) orientation so digits read
   correctly, so it is NOT flipped like the live video/overlay. */
.freeze {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 2;
}
.result-actions {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  background: linear-gradient(0deg, rgba(17,22,27,0.78), transparent);
}
.solved-flag {
  font-family: "Cinzel", Georgia, serif;
  letter-spacing: 0.08em;
  color: #fff;
  background: var(--green);
  padding: 7px 16px;
  border-radius: 999px;
  font-size: 0.82rem;
  box-shadow: var(--shadow);
}

/* ---- Permission gate ---- */
.gate {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(17,22,27,0.82), rgba(17,22,27,0.92));
  color: var(--offwhite);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px;
  gap: 10px;
  transition: opacity 0.25s ease;
}
.gate.hidden { opacity: 0; pointer-events: none; }
.gate-mark { height: 72px; opacity: 0.95; filter: brightness(0) invert(1); }
.gate h2 {
  font-family: "Cinzel", Georgia, serif;
  font-weight: 600;
  letter-spacing: 0.04em;
  margin: 6px 0 0;
  font-size: 1.25rem;
}
.gate p {
  max-width: 380px;
  font-size: 0.88rem;
  line-height: 1.5;
  color: rgba(243, 241, 236, 0.8);
  margin: 0;
}

/* ---- Buttons ---- */
.btn-primary {
  margin-top: 10px;
  background: var(--teal);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 12px 26px;
  font-family: "Montserrat", sans-serif;
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.2s ease;
}
.btn-primary:hover { background: #259187; transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.btn-ghost {
  width: 100%;
  background: transparent;
  color: var(--slate);
  border: 1.5px solid var(--slate);
  border-radius: 10px;
  padding: 11px;
  font-family: "Montserrat", sans-serif;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}
.btn-ghost:hover:not(:disabled) { background: var(--slate); color: #fff; }
.btn-ghost:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-ghost.danger { color: var(--red); border-color: var(--red); }
.btn-ghost.danger:hover:not(:disabled) { background: var(--red); color: #fff; }

.panel-actions { display: flex; gap: 10px; }
.panel-actions .btn-ghost { flex: 1; }

/* ---- Panel ---- */
.panel { display: flex; flex-direction: column; gap: 18px; }

.status-card, .metric, .board-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.status-pill {
  display: inline-block;
  font-family: "Cinzel", Georgia, serif;
  letter-spacing: 0.06em;
  font-size: 0.82rem;
  padding: 6px 14px;
  border-radius: 999px;
  color: #fff;
  background: var(--charcoal);
}
.status-pill[data-state="looking"] { background: var(--azure); }
.status-pill[data-state="reading"] { background: var(--gold); color: var(--ink); }
.status-pill[data-state="solved"]  { background: var(--green); }
.status-pill[data-state="error"]   { background: var(--red); }
.status-detail {
  margin: 12px 0 0;
  color: var(--charcoal);
  font-size: 0.9rem;
  line-height: 1.45;
}

/* ---- Metric / confidence ---- */
.metric-head {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--slate);
}
.bar {
  position: relative;
  height: 12px;
  background: #eceae4;
  border-radius: 999px;
  margin: 12px 0 8px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--azure);
  transition: width 0.3s ease, background 0.3s ease;
}
.bar-threshold {
  position: absolute;
  top: -2px;
  bottom: -2px;
  left: 99%;
  width: 2px;
  background: var(--slate-dark);
  opacity: 0.5;
}
.metric-sub { margin: 0; font-size: 0.78rem; color: var(--charcoal); }

/* ---- Mini board ---- */
.board-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--slate);
  margin-bottom: 12px;
}
.legend { font-weight: 500; color: var(--charcoal); font-size: 0.72rem; }
.dot {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  margin: 0 2px 0 8px;
  vertical-align: middle;
}
.dot.given { background: var(--slate); }
.dot.solved { background: var(--teal); }

.mini-board {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  aspect-ratio: 1;
  border: 2px solid var(--slate);
  border-radius: 6px;
  overflow: hidden;
}
.mini-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Montserrat", sans-serif;
  font-weight: 600;
  font-size: clamp(0.7rem, 2.2vw, 1rem);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--slate);
  background: #fff;
}
.mini-cell.solved { color: var(--teal); background: rgba(43, 161, 151, 0.07); }
.mini-cell.empty { color: transparent; }
/* 3x3 block separators */
.mini-cell:nth-child(9n) { border-right: none; }
.mini-cell:nth-child(3n):not(:nth-child(9n)) { border-right: 2px solid var(--slate); }
.mini-board > .mini-cell:nth-child(n+19):nth-child(-n+27),
.mini-board > .mini-cell:nth-child(n+46):nth-child(-n+54) {
  border-bottom: 2px solid var(--slate);
}

/* ---- Info: How it works + Built with ---- */
.info {
  width: min(1100px, 94vw);
  margin: 44px auto 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}
@media (max-width: 820px) {
  .info { grid-template-columns: 1fr; }
}
.info-block {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: var(--shadow);
}
.section-title {
  font-family: "Cinzel", Georgia, serif;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--slate);
  font-size: 1.05rem;
  margin: 0 0 20px;
  text-transform: uppercase;
}

.steps { list-style: none; margin: 0; padding: 0; }
.steps li {
  display: flex;
  gap: 16px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}
.steps li:first-child { border-top: none; padding-top: 0; }
.step-num {
  font-family: "Cinzel", Georgia, serif;
  font-size: 1.1rem;
  color: var(--teal);
  font-weight: 600;
  min-width: 28px;
}
.steps h3 {
  margin: 0 0 4px;
  font-size: 0.95rem;
  color: var(--slate);
  font-weight: 600;
}
.steps p {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.5;
  color: var(--charcoal);
}

.skill-groups { display: flex; flex-direction: column; gap: 18px; }
.skill-group h3 {
  margin: 0 0 10px;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--charcoal);
  font-weight: 600;
}
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  display: inline-block;
  padding: 6px 13px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--slate);
  background: rgba(63, 93, 115, 0.08);
  border: 1px solid var(--line);
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}
.pill:hover {
  background: var(--slate);
  color: #fff;
  transform: translateY(-1px);
}

/* ---- Footer ---- */
.site-footer {
  text-align: center;
  padding: 22px;
  color: var(--charcoal);
  font-family: "Cinzel", Georgia, serif;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.68rem;
}
.site-footer .sep { margin: 0 8px; color: var(--taupe); }
