/* LesS/KEY web app. Visual language mirrored from kaizenkodo.org
   (~/Repos/Identity/website/main.css): washi-paper cream, ocean blue, hanko red,
   Poppins / Inter / JetBrains Mono. Light, responsive, restrained. */

:root {
  --cream: #f4f0e8;
  --paper: #fbf8f2;
  --ink: #15181b;
  --muted: #6a675e;
  --line: #ddd6c6;
  --ocean: #1b4161;
  --ocean-2: #2f6286;
  --deep: #0a2540;
  --seal: #e23b2e;
  --disp: "Poppins", system-ui, sans-serif;
  --body: "Inter", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --maxw: 1320px;
  --gutter: clamp(16px, 3.5vw, 48px);
  --radius: 16px;
}

/* Self-hosted fonts, bundled with the app so it makes NO external requests and
   talks to no third party (no Google Fonts, no CDN). Latin subset only. */
@font-face { font-family:"Poppins"; font-style:normal; font-weight:600; font-display:swap; src:url("./assets/fonts/Poppins-600.woff2") format("woff2"); }
@font-face { font-family:"Poppins"; font-style:normal; font-weight:700; font-display:swap; src:url("./assets/fonts/Poppins-700.woff2") format("woff2"); }
@font-face { font-family:"Inter"; font-style:normal; font-weight:400; font-display:swap; src:url("./assets/fonts/Inter-400.woff2") format("woff2"); }
@font-face { font-family:"Inter"; font-style:normal; font-weight:500; font-display:swap; src:url("./assets/fonts/Inter-500.woff2") format("woff2"); }
@font-face { font-family:"Inter"; font-style:normal; font-weight:600; font-display:swap; src:url("./assets/fonts/Inter-600.woff2") format("woff2"); }
@font-face { font-family:"JetBrains Mono"; font-style:normal; font-weight:400; font-display:swap; src:url("./assets/fonts/JetBrainsMono-400.woff2") format("woff2"); }
@font-face { font-family:"JetBrains Mono"; font-style:normal; font-weight:500; font-display:swap; src:url("./assets/fonts/JetBrainsMono-500.woff2") format("woff2"); }
/* Masked-secret font: dots glyphs so the real chars stay selectable/copyable.
   WebKit/Blink use -webkit-text-security; Firefox falls back to this font. */
@font-face { font-family:"text-security-disc"; font-display:swap; src:url("./assets/fonts/text-security-disc.woff2") format("woff2"); }

* { margin: 0; padding: 0; box-sizing: border-box; }
html { height: 100%; overflow-x: hidden; overscroll-behavior-x: none; }

body {
  min-height: 100%;
  overflow-x: hidden;             /* no sideways pan; page is single column */
  overscroll-behavior-x: none;    /* kill horizontal rubber-band / swipe-nav */
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background-color: var(--cream);
  background-image:
    linear-gradient(rgba(27, 65, 97, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(27, 65, 97, 0.05) 1px, transparent 1px);
  background-size: 48px 48px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding-inline: var(--gutter); }

/* Header */
.site {
  position: sticky; top: 0; z-index: 50;
  background: rgba(244, 240, 232, 0.82);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.nav { display: flex; align-items: center; gap: 14px; height: 68px; }
.brand { display: inline-flex; align-items: center; gap: 11px; text-decoration: none; }
.enso { width: 36px; height: 36px; display: block; flex: none; object-fit: contain; }
.wordmark { font-family: var(--disp); font-weight: 700; font-size: 22px; color: var(--ocean); letter-spacing: -0.01em; }
.tagline { font-family: var(--mono); font-size: 11px; color: var(--muted); letter-spacing: 0.08em; }
.nav-spacer { flex: 1; }
/* Always-visible link back to the main Kaizenkodo site. */
.backlink { display: inline-flex; align-items: center; gap: 5px; flex: none; font-family: var(--mono); font-size: 12px; letter-spacing: 0.03em; color: var(--muted); text-decoration: none; white-space: nowrap; padding: 6px 11px; border-radius: 999px; border: 1px solid var(--line); }
.backlink:hover { color: var(--ocean); border-color: var(--ocean); background: rgba(27, 65, 97, 0.05); }
.backlink .arr { font-size: 14px; line-height: 1; }
/* Installed as a home-screen app (standalone launch): hide the back-to-site link.
   With it gone there's room, so show the wordmark again even on narrow phones
   (higher specificity than the <=540px hide, so it wins regardless of order). */
@media (display-mode: standalone) { .backlink { display: none; } }
html.standalone .backlink { display: none; }
html.standalone .wordmark { display: inline; }

/* Eyebrow label */
.eyebrow {
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--ocean);
  display: inline-flex; align-items: center; gap: 9px; margin-bottom: 12px;
}
.eyebrow::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: var(--seal); box-shadow: 0 0 0 3px rgba(226, 59, 46, 0.16);
}

/* minmax(0,1fr) lets the cards shrink below their content's intrinsic width, so
   the console's pre/no-wrap lines scroll inside it instead of widening the page. */
main { padding: clamp(20px, 3vw, 34px) 0 56px; display: grid; grid-template-columns: minmax(0, 1fr); gap: clamp(16px, 2.4vw, 24px); }

/* About / how-it-works (collapsible <details>) */
.about { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.about > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 12px;
  padding: clamp(14px, 2.2vw, 19px) clamp(16px, 2.6vw, 28px);
  font-family: var(--disp); font-weight: 600; font-size: clamp(16px, 2vw, 20px); color: var(--ocean);
}
.about > summary::-webkit-details-marker { display: none; }
.about > summary:hover { color: var(--ocean-2); }
/* attention badge; draws the eye to open the help panel; hidden once open */
.about-badge {
  font-family: var(--mono); font-size: 10.5px; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: #fff; background: var(--seal); border-radius: 999px; padding: 3px 10px; flex: none;
  animation: badgePulse 2.2s ease-out infinite;
}
@keyframes badgePulse {
  0% { box-shadow: 0 0 0 0 rgba(226, 59, 46, 0.45); }
  70% { box-shadow: 0 0 0 9px rgba(226, 59, 46, 0); }
  100% { box-shadow: 0 0 0 0 rgba(226, 59, 46, 0); }
}
@media (prefers-reduced-motion: reduce) { .about-badge { animation: none; } }
.about-hint { font-family: var(--mono); font-size: 11px; font-weight: 400; color: var(--muted); }
.about[open] .about-badge, .about[open] .about-hint { display: none; }
@media (max-width: 680px) { .about-hint { display: none; } }
.about .about-toggle {
  margin-left: auto; width: 9px; height: 9px; flex: none;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(45deg); transition: transform .2s;
}
.about[open] .about-toggle { transform: rotate(-135deg); }
.about-body { padding: 0 clamp(16px, 2.6vw, 28px) clamp(16px, 2.6vw, 24px); }
.about-body p { color: var(--muted); font-size: 14.5px; }
.about-body > p:first-child { color: var(--ink); font-size: 15.5px; }
.about-body code { font-family: var(--mono); font-size: 12px; color: var(--ocean-2); background: rgba(27,65,97,.06); padding: 1px 5px; border-radius: 5px; }
.about-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin: 18px 0 6px; }
.about-grid h4 { font-family: var(--disp); font-weight: 600; font-size: 14px; color: var(--ink); margin-bottom: 5px; }
.about-grid p { font-size: 13.5px; }
.about-note { font-family: var(--mono); font-size: 12px; margin-top: 10px; }
/* Privacy callout; make the "no server" promise visually prominent. */
.about-privacy {
  margin: 6px 0 2px; padding: 13px 16px; border-radius: 12px;
  border: 1px solid var(--line); border-left: 3px solid var(--ocean);
  background: rgba(27, 65, 97, 0.045); color: var(--ink); font-size: 14.5px;
}
.about-privacy strong { color: var(--ocean); }
@media (max-width: 680px) { .about-grid { grid-template-columns: 1fr; } }

/* Cards */
.card {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); padding: clamp(16px, 2.6vw, 28px);
}
.card h2 { font-family: var(--disp); font-weight: 600; font-size: clamp(20px, 2.6vw, 27px); color: var(--ink); margin-bottom: 4px; }
.card .hint { color: var(--muted); font-size: 14px; margin-bottom: 18px; }
.card .hint code { font-family: var(--mono); font-size: 12.5px; color: var(--ocean-2); background: rgba(27,65,97,0.06); padding: 1px 5px; border-radius: 5px; }

/* Form fields */
.fields { display: grid; grid-template-columns: 1.5fr 1fr; gap: 14px; align-items: end; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
input[type="text"], input[type="password"] {
  /* 16px min: iOS Safari auto-zooms (and stays zoomed) when a focused input is
     under 16px. Keep all focusable fields >= 16px to stop that. */
  font-family: var(--mono); font-size: 16px; color: var(--ink);
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; width: 100%; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus { border-color: var(--ocean); box-shadow: 0 0 0 3px rgba(27, 65, 97, 0.12); }
/* Masked TEXT inputs (master, pass overlay): visually masked but type=text, so
   the browser never treats them as password fields, so no autofill / save / "suggest
   strong password". Firefox uses the bundled disc font. */
input.mask { -webkit-text-security: disc; }
@supports not (-webkit-text-security: disc) { input.mask { font-family: "text-security-disc", var(--mono); } }
/* Click the masked master field to reveal what you typed; click again to re-mask. */
#master { cursor: pointer; }
input.mask.revealed { -webkit-text-security: none; }
@supports not (-webkit-text-security: disc) { input.mask.revealed { font-family: var(--mono); } }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer; white-space: nowrap;
  font-family: var(--disp); font-weight: 600; font-size: 14px;
  background: var(--ocean); color: var(--cream);
  border: 1px solid var(--ocean); border-radius: 999px; padding: 10px 20px;
  transition: transform .15s, background .15s, border-color .15s;
}
.btn:hover { transform: translateY(-1px); background: var(--deep); border-color: var(--deep); }
.btn:active { transform: none; }
.btn.ghost { background: transparent; color: var(--ocean); }
.btn.ghost:hover { background: rgba(27, 65, 97, 0.06); color: var(--ocean); border-color: var(--ocean); }
.btn.small { padding: 7px 15px; font-size: 13px; }
/* Confirmed states ("Correct ✓" / "Stored ✓"): same filled-ocean look for both. */
.btn.small.is-correct,
.btn.small.is-stored { background: var(--ocean); color: var(--cream); border-color: var(--ocean); }
.btn.small.is-correct:hover { background: var(--deep); border-color: var(--deep); }
.btn:disabled { opacity: .4; cursor: not-allowed; pointer-events: none; }
/* is-stored is disabled (re-storing is a no-op); keep it fully opaque, not dimmed. */
.btn.small.is-stored { opacity: 1; }

/* Quick-gen result row */
.result {
  display: flex; align-items: center; flex-wrap: wrap; gap: 12px;
  margin-top: 20px; padding: 14px 16px; border: 1px solid var(--line);
  border-radius: 12px; background: #fff; min-height: 58px;
}
.result .tag { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.result .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.result .len { font-family: var(--mono); font-size: 11px; color: var(--muted); }
/* Quick-gen result: dynamic font (scales down on narrow phones) and wraps so a
   long password stays inside the card. min-width:0 lets it shrink/wrap within
   the flex row. Scoped so the console table keeps its fixed-width alignment. */
.result .secret { font-size: clamp(13px, 4vw, 19px); white-space: pre-wrap; overflow-wrap: anywhere; min-width: 0; }

/* Secret rendering: real text in the DOM, visually masked. Click toggles.
   Mask via -webkit-text-security on the MONO font so each disc keeps the mono
   advance width, so gen tables stay aligned. (No letter-spacing, no disc webfont
   here, both of which would break the column widths.) */
.secret {
  font-family: var(--mono);
  -webkit-text-security: disc;
  font-size: 19px; color: var(--ink);
  cursor: pointer; user-select: text; white-space: pre;
}
/* Reveal flips masking only; colour is reserved for correctness (below). */
.secret.revealed { -webkit-text-security: none; }
/* Quick-gen result: ocean = this master is marked correct; otherwise ink ("black"). */
.result .secret.correct { color: var(--ocean); font-weight: 500; }
/* Console keeps its old cue: a revealed secret turns ocean. */
.console-out .secret.revealed { color: var(--ocean); }
/* Firefox lacks -webkit-text-security: fall back to the disc webfont for masking
   (single-line result only; the console table is a WebKit/Blink concern). */
@supports not (-webkit-text-security: disc) {
  .secret { font-family: "text-security-disc", var(--mono); }
  .secret.revealed { font-family: var(--mono); }
}
.secret:empty::before { content: "type a name + master"; color: var(--muted); font-size: 14px; -webkit-text-security: none; font-family: var(--body); cursor: default; }

/* Console */
.console-out {
  font-family: var(--mono); font-size: 13.5px; line-height: 1.55;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 14px; height: clamp(280px, 46vh, 560px);
  overflow: auto; white-space: pre;            /* no wrap, scroll left/right */
}
.console-out > div { min-width: max-content; }
.console-out .cmd { color: var(--ocean); font-weight: 500; }
.console-out .err { color: var(--seal); }
.console-out .muted { color: var(--muted); }
.console-out .secret { font-size: 13.5px; vertical-align: baseline; }
.console-in { display: flex; align-items: center; gap: 8px; margin-top: 10px;
  background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 4px 14px; }
.console-in:focus-within { border-color: var(--ocean); box-shadow: 0 0 0 3px rgba(27,65,97,0.12); }
.console-in .prompt { font-family: var(--mono); color: var(--ocean); font-weight: 600; }
.console-in input { border: none; box-shadow: none; padding: 9px 0; background: transparent; }
.console-in input:focus { box-shadow: none; }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: var(--deep); color: var(--cream); font-family: var(--mono); font-size: 13px;
  padding: 10px 18px; border-radius: 999px; box-shadow: 0 8px 24px rgba(10, 16, 24, 0.35);
  opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 80;
}
.toast.show { opacity: 1; }

/* Modal (import/export) */
.modal-bg {
  position: fixed; inset: 0; background: rgba(10, 16, 24, 0.45);
  display: none; align-items: center; justify-content: center; padding: 20px; z-index: 90;
}
.modal-bg.show { display: flex; }
.modal { background: var(--paper); border-radius: 18px; border: 1px solid var(--line);
  width: 100%; max-width: 680px; padding: 24px; }
.modal h3 { font-family: var(--disp); font-weight: 600; margin-bottom: 10px; }
.modal textarea {
  width: 100%; height: 260px; resize: vertical; font-family: var(--mono); font-size: 16px;
  border: 1px solid var(--line); border-radius: 10px; padding: 12px; outline: none; white-space: pre;
}
.modal textarea:focus { border-color: var(--ocean); }
.modal .row { display: flex; gap: 10px; margin-top: 14px; }

/* padding-block only: keep .wrap's inline gutter so the footer lines up with the
   body cards instead of running to the window edge. */
.foot { color: var(--muted); font-family: var(--mono); font-size: 12px; text-align: center; padding-block: 8px 40px; }
.foot a { color: var(--ocean); text-decoration: none; border-bottom: 1px solid rgba(27, 65, 97, 0.3); }
.foot a:hover { border-bottom-color: var(--ocean); }
/* Version badge: a quiet mono pill under the footer prose (mirrors .backlink).
   Decent and out of the way; click opens the changelog overlay. */
.ver {
  display: inline-block; margin-top: 10px;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.04em;
  color: var(--muted); background: transparent;
  border: 1px solid var(--line); border-radius: 999px; padding: 3px 11px;
  cursor: pointer; transition: color .15s, border-color .15s, background .15s;
}
.ver:hover { color: var(--ocean); border-color: var(--ocean); background: rgba(27, 65, 97, 0.05); }
.ver:focus-visible { outline: none; border-color: var(--ocean); box-shadow: 0 0 0 3px rgba(27, 65, 97, 0.12); }

/* Changelog overlay body (inside the shared .modal). Scrolls if it ever grows. */
.changelog { max-height: 60vh; overflow: auto; margin-top: 4px; }
.cl-entry { padding: 16px 0; border-top: 1px solid var(--line); }
.cl-entry:first-child { border-top: none; padding-top: 2px; }
.cl-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 3px; }
.cl-ver { font-family: var(--disp); font-weight: 700; font-size: 16px; color: var(--ocean); letter-spacing: -0.01em; }
.cl-date { font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em; color: var(--muted); }
/* "Latest" flag, pushed to the right edge of the newest release's head. */
.cl-latest {
  margin-left: auto; flex: none; align-self: center;
  font-family: var(--mono); font-size: 9.5px; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: #fff; background: var(--seal); border-radius: 999px; padding: 2px 9px;
}
/* Release theme line under the version. */
.cl-title { font-family: var(--disp); font-weight: 600; font-size: 14px; color: var(--ink); margin: 0 0 12px; }
.changelog ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 9px; }
.changelog li { display: flex; align-items: baseline; gap: 12px; color: var(--ink); font-size: 14px; line-height: 1.5; }
/* Category tag in a fixed-width column, so the change text shares one clean left edge. */
.cl-tag {
  flex: none; width: 68px; text-align: center; box-sizing: border-box;
  font-family: var(--mono); font-size: 9.5px; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.08em;
  padding: 3px 0; border-radius: 6px; transform: translateY(-1px);
}
.cl-tag-new { color: var(--ocean); background: rgba(27, 65, 97, 0.10); }
.cl-tag-improved { color: var(--muted); background: rgba(106, 103, 94, 0.13); }
.cl-text { min-width: 0; }
.changelog code { font-family: var(--mono); font-size: 12px; color: var(--ocean-2); background: rgba(27,65,97,.06); padding: 1px 5px; border-radius: 5px; }
/* On phones the fixed tag column would crowd the text — let each item stack. */
@media (max-width: 540px) {
  .changelog li { flex-wrap: wrap; gap: 5px 10px; }
  .cl-tag { width: auto; padding: 3px 9px; }
}

@media (max-width: 680px) {
  .fields { grid-template-columns: 1fr; align-items: stretch; }
  .nav { gap: 9px; height: 60px; }
  .tagline { display: none; }
  body { font-size: 15px; }
  /* free space for the back link: the ensō icon alone carries the brand on phones */
  .backlink { padding: 5px 9px; }
  /* result row stacks cleanly on phones: the password on its own full-width line,
     then a tidy meta line (result + len ........ Copy / Store). */
  .result { align-items: center; row-gap: 12px; }
  .result .secret { order: 1; flex: 1 1 100%; font-size: clamp(15px, 5.2vw, 19px); }
  .result .tag { order: 2; }
  .result .len { order: 3; margin-right: auto; }
  .result .actions { order: 4; margin-left: 0; }
}
/* On narrow phones drop the wordmark so the back link + ensō + buttons all fit. */
@media (max-width: 540px) { .wordmark { display: none; } }
