/* Asterisk: an earnest security form. The chrome stays quiet and corporate
   so the asterisks carry all the personality. */

:root {
  --paper: #f2f3ef;
  --card: #ffffff;
  --ink: #18202c;
  --slate: #566172;
  --rule: #d3d8de;
  --hint: #9aa3ae;
  --signal: #1f4fd1;
  --signal-wash: #edf1fc;
  --track: #e6e9ed;
  --weak: #c2410c;
  --fair: #a86a12;
  --strong: #2f7d4f;
  --radius: 8px;
  --ui: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.5 var(--ui);
  -webkit-font-smoothing: antialiased;
}

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

:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }

/* ---- layout ------------------------------------------------------------ */

.shell {
  max-width: 720px; /* room for 12 boxes in one row */
  margin: 0 auto;
  padding: clamp(16px, 4vh, 40px) 16px 16px; /* lean, so signup can fit one window */
}

.brand { display: flex; align-items: center; margin: 0 0 20px; }
.brand { margin-bottom: clamp(16px, 3vw, 28px); }
.brand-logo { display: block; width: auto; height: clamp(56px, 9vw, 96px); }
@media (max-width: 600px) {
  .brand { margin-bottom: 10px; }
  .brand-logo { height: 28px; } /* phones need the height for the hint */
}

.card {
  --card-pad: clamp(20px, 5vw, 36px);
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: var(--card-pad);
}

/* Sits right under the hint. The hint is sized so both fit on one screen,
   so nothing needs to be pinned on top of it. */
.form-actions { margin-top: 16px; }

h1 {
  margin: 0 0 8px;
  font-size: clamp(22px, 4vw, 26px); font-weight: 600; line-height: 1.25;
}

.lede { margin: 0 0 28px; color: var(--slate); max-width: 46ch; }
.lede strong { color: var(--ink); font-weight: 600; }

/* ---- password field ---------------------------------------------------- */

.field { margin-bottom: 20px; }
.field-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0 12px; }
.field-head .field-label { margin: 0; }
.field-head .link { font-size: 14px; }
.pw-wrap { position: relative; }

.field-label { margin: 0 0 6px; font-size: 14px; font-weight: 600; }

/* One box per character, like a verification-code field. */
.pw {
  display: flex; flex-wrap: wrap; gap: 6px;
  min-height: 60px;
}

#signup-field, #signin-field { min-height: 60px; } /* reserve the row before fonts.json arrives */

.char {
  position: relative;
  width: 44px; height: 60px;
  padding: 0;
  border: 1px solid var(--rule); border-radius: var(--radius);
  background: var(--card);
  color: var(--hint);
  cursor: pointer;
  overflow: hidden;
  transition: border-color 120ms ease, background-color 120ms ease;
}
/* Asterisks sit near cap height, so drop the line box to center the glyph in the box.
   Each font's own asterisk height still shows, which is part of the fun. */
.char-star {
  position: absolute; left: 0; right: 0; top: 13px;
  font: 400 44px/1 var(--ui);
  text-align: center;
}
.char:hover { border-color: var(--slate); }
.char.is-set { color: var(--ink); border-color: #aab2bd; }
.char.is-editing {
  border-color: var(--signal); background: var(--signal-wash);
  box-shadow: 0 0 0 1px var(--signal);
}

/* ---- security meter ---------------------------------------------------- */

/* Signup puts the meter beside the form on wide screens and pins it to the top
   of the viewport on narrow ones, so the font picker never covers it. */
.signup-layout { display: grid; gap: 16px; align-items: start; }
.signup-layout[hidden] { display: none; }

.meter-panel {
  position: sticky; top: 0; z-index: 5;
  margin: 0 -16px; padding: 12px 16px;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
}
.meter-panel .meter-hint { min-height: 0; font-size: 13px; }

@media (min-width: 1040px) {
  /* Logo and meter share the left column so the form starts at the top of
     the window, which leaves the hint as much height as possible. */
  body[data-view="signup"] .shell {
    max-width: 1000px;
    display: grid; grid-template-columns: 240px minmax(0, 1fr);
    grid-template-rows: auto 1fr; column-gap: 16px; align-items: start;
  }
  body[data-view="signup"] .brand { grid-column: 1; grid-row: 1; }
  body[data-view="signup"] .brand-logo { width: 100%; height: auto; }
  body[data-view="signup"] .signup-layout { display: contents; }
  .signup-layout > .meter-panel { grid-column: 1; grid-row: 2; }
  .signup-layout > .card { grid-column: 2; grid-row: 1 / span 2; }
  .meter-panel {
    top: 24px; margin: 0; padding: 18px;
    background: var(--card);
    border: 1px solid var(--rule); border-radius: 12px;
  }
  .meter-panel .meter-hint { min-height: 4.5em; font-size: 14px; }
}

.meter { margin: 0; }

.site-footer {
  margin-top: 16px; padding: 4px 0;
  font-size: 13px; color: var(--slate); text-align: center;
}
.site-footer a {
  display: inline-block; padding: 12px 2px; /* comfortable tap target */
  color: var(--ink); font-weight: 600;
  text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--rule);
}
.site-footer a:hover { text-decoration-color: currentColor; }
@media (min-width: 1040px) {
  body[data-view="signup"] .site-footer { grid-column: 2; } /* centered under the form */
}

/* Taste sits under security on wide screens and beside it in the narrow bar. */
.taste { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--rule); }
.taste-level { color: var(--slate); }
.taste-level[data-level="impeccable"], .taste-level[data-level="refined"] { color: var(--signal); }
.taste-level[data-level="questionable"] { color: var(--fair); }
.taste-level[data-level="concerning"] { color: var(--weak); }
.taste-pips { display: flex; gap: 4px; }
.taste-pips span {
  flex: 1; height: 6px; border-radius: 3px; background: var(--track);
  transition: background-color 200ms ease;
}
.taste-pips span.is-on { background: var(--ink); }
.taste-pips[data-pips="1"] span.is-on { background: var(--weak); }
.taste-pips[data-pips="2"] span.is-on { background: var(--fair); }
.taste-pips[data-pips="4"] span.is-on, .taste-pips[data-pips="5"] span.is-on { background: var(--signal); }

@media (max-width: 1039px) {
  .meter-panel { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
  .taste { margin-top: 0; padding-top: 0; border-top: 0; padding-left: 16px; border-left: 1px solid var(--rule); }
  .meter-panel .meter-head { font-size: 13px; }
  .meter-panel .meter-hint { font-size: 12px; line-height: 1.4; }
}
.meter-head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  font-size: 14px; font-weight: 600; margin-bottom: 6px;
}
.meter-level { color: var(--slate); }
.meter-level[data-level="weak"] { color: var(--weak); }
.meter-level[data-level="fair"] { color: var(--fair); }
.meter-level[data-level="strong"], .meter-level[data-level="very-strong"] { color: var(--strong); }

.meter-track { height: 6px; border-radius: 3px; background: var(--track); overflow: hidden; }
.meter-fill {
  height: 100%; width: 100%;
  transform: scaleX(0); transform-origin: left;
  background: var(--slate);
  transition: transform 360ms cubic-bezier(.2, .7, .2, 1), background-color 200ms ease;
}
.meter-track[data-level="weak"] .meter-fill { background: var(--weak); }
.meter-track[data-level="fair"] .meter-fill { background: var(--fair); }
.meter-track[data-level="strong"] .meter-fill,
.meter-track[data-level="very-strong"] .meter-fill { background: var(--strong); }

.meter-hint { margin: 8px 0 0; font-size: 14px; color: var(--slate); min-height: 3em; }
.meter-level[data-level="unreasonable"] { color: var(--strong); }
.meter-track[data-level="unreasonable"] .meter-fill {
  /* past 100%: the bar is full, so let it shimmer a little */
  background: repeating-linear-gradient(-45deg, var(--strong) 0 8px, #3f9a65 8px 16px);
}

/* ---- password hint --------------------------------------------------------- */

.hint-field { margin-top: -4px; }
.optional { font-weight: 400; color: var(--slate); }
.field-help { margin: 0 0 8px; font-size: 14px; color: var(--slate); }
label.field-label { display: block; margin-bottom: 4px; }

/* Room for the whole memory palace: it fills whatever height the browser has
   left, so the page fits the window with Create account at the bottom
   (app.js measures this into --hint-fit). Long hints scroll inside the box.
   Dragging can shrink it but never push it past the window. */
.hint {
  display: block; width: 100%;
  height: var(--hint-fit, 240px);
  max-height: var(--hint-fit, none);
  min-height: 140px;
  overflow-y: auto;
  padding: 16px;
  border: 1px solid var(--rule); border-radius: var(--radius);
  background: var(--card);
  font: 400 16px/1.6 var(--ui); color: var(--ink);
  resize: vertical;
}
.hint:focus { outline: 2px solid var(--signal); outline-offset: -1px; border-color: transparent; }
.hint[aria-invalid="true"] { border-color: var(--weak); }
.hint-meta { margin-top: 6px; font-size: 13px; color: var(--slate); text-align: right; }
.hint-field .error { margin-top: 8px; }

.hint-reveal {
  margin-top: 16px; padding: 14px 16px;
  border: 1px solid var(--rule); border-radius: var(--radius); background: #fafbf9;
}
.hint-reveal-title { margin: 0 0 6px; font-size: 14px; font-weight: 600; }
.hint-reveal-text {
  max-height: 320px; overflow-y: auto;
  white-space: pre-wrap; overflow-wrap: anywhere;
  font-size: 15px; color: var(--ink);
}
.hint-reveal-text.is-empty { color: var(--slate); }
.aside + .aside { margin-top: 0; }

/* ---- extra-secure layer -------------------------------------------------- */

.extra {
  margin: 4px 0 8px; padding: 14px 16px;
  border: 1px dashed var(--rule); border-radius: var(--radius);
  font-size: 14px; color: var(--slate);
}
.extra p { margin: 0 0 10px; }
.extra-title { color: var(--ink); font-weight: 600; margin-bottom: 4px !important; }
.extra .link { min-height: 32px; font-size: 14px; }
.extra-note {
  margin: -16px 0 24px; padding: 10px 14px;
  border-left: 3px solid var(--signal); background: var(--signal-wash);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 14px;
}

.secondary {
  min-height: 44px; padding: 0 16px;
  border: 1px solid var(--rule); border-radius: var(--radius); background: var(--card);
  color: var(--ink); font: 600 15px var(--ui); cursor: pointer;
}
.secondary:hover { border-color: var(--slate); }

.styler {
  margin-top: 12px; padding: 14px 16px 16px;
  border: 1px solid var(--rule); border-radius: var(--radius); background: #fafbf9;
}
.styler-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 4px 12px; }
.styler-title { margin: 0; font-size: 14px; font-weight: 600; }
.styler-font { font-weight: 400; color: var(--slate); }
.styler-change { min-height: 32px; font-size: 14px; }
.styler-label { margin: 12px 0 6px; font-size: 13px; font-weight: 600; color: var(--slate); }

.styler-weights, .styler-styles { display: flex; flex-wrap: wrap; gap: 6px; }
.styler-weight {
  display: grid; grid-template-rows: 34px auto; justify-items: center;
  width: 48px; padding: 4px 0 6px;
  border: 1px solid var(--rule); border-radius: 6px; background: var(--card);
  color: var(--ink); cursor: pointer; overflow: hidden;
}
.styler-star { font-size: 34px; line-height: 44px; height: 34px; opacity: 0; transition: opacity 160ms ease; }
.styler-star.is-ready { opacity: 1; }
.styler-star.no-fade { transition: none; }
.styler-num { font-size: 11px; color: var(--slate); }
.styler-style {
  min-height: 40px; padding: 0 14px;
  border: 1px solid var(--rule); border-radius: 6px; background: var(--card);
  font: 400 14px var(--ui); color: var(--ink); cursor: pointer;
}
.styler-weight[aria-pressed="true"], .styler-style[aria-pressed="true"] {
  border-color: var(--signal); background: var(--signal-wash); box-shadow: inset 0 0 0 1px var(--signal);
}
.styler-style:disabled { color: var(--hint); cursor: not-allowed; background: var(--paper); }
.styler-note { margin: 10px 0 0; font-size: 13px; color: var(--slate); }

/* ---- buttons ----------------------------------------------------------- */

.link {
  min-height: 44px; padding: 0;
  border: 0; background: none;
  color: var(--signal); font: inherit; font-weight: 600;
  cursor: pointer;
}
.link:hover { text-decoration: underline; text-underline-offset: 3px; }

.primary {
  width: 100%; min-height: 48px;
  border: 0; border-radius: var(--radius);
  background: var(--signal); color: #fff;
  font: 600 16px var(--ui);
  cursor: pointer;
}
.primary:disabled { background: var(--rule); color: var(--slate); cursor: not-allowed; }

.done {
  margin-top: 20px; padding: 14px 16px;
  border-left: 3px solid var(--signal); background: var(--signal-wash);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.done p { margin: 0; }
.done-title { font-weight: 600; }
.done-action { margin-top: 14px; }

.error {
  margin-top: 12px; padding: 10px 14px;
  border-left: 3px solid var(--weak); background: #fdf1ec;
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 14px; color: #7a2a08;
}

.aside { margin: 16px 0 0; font-size: 14px; color: var(--slate); text-align: center; }
.aside .link { font-size: 14px; }

h1:focus { outline: none; } /* focused only to move screen readers to the new view */

/* ---- font picker ------------------------------------------------------- */

.picker {
  position: absolute; z-index: 10;
  top: calc(100% + 6px); left: 0;
  width: min(440px, 100%);
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(24, 32, 44, 0.16);
  overflow: hidden;
}
.picker[hidden] { display: none; } /* the phone layout sets display: flex */

.picker-title { margin: 0; padding: 12px 14px 0; font-size: 13px; font-weight: 600; }

.picker-head {
  display: flex; gap: 4px; align-items: center;
  padding: 8px; border-bottom: 1px solid var(--rule);
}
.picker-search {
  flex: 1; min-width: 0; height: 44px;
  padding: 0 12px;
  border: 1px solid var(--rule); border-radius: var(--radius);
  font: 400 16px var(--ui); color: var(--ink);
}
.picker-search::-webkit-search-cancel-button { display: none; } /* one close button is plenty */
.picker-search:focus { outline: 2px solid var(--signal); outline-offset: -1px; border-color: transparent; }
.picker-close {
  display: grid; place-items: center;
  width: 44px; height: 44px; flex: none;
  border: 0; border-radius: var(--radius); background: none;
  color: var(--slate); cursor: pointer;
}
.picker-close:hover { background: var(--paper); }

.picker-count { margin: 0; padding: 8px 14px 4px; font-size: 13px; color: var(--slate); }

.picker-scroll {
  height: 336px; /* six rows */
  overflow-y: auto; overscroll-behavior: contain;
}
.picker-list { position: relative; }

.opt {
  position: absolute; top: 0; left: 0; right: 0;
  height: 56px; /* keep in sync with ROW in picker.js */
  display: grid; grid-template-columns: 64px 1fr; align-items: center;
  padding-right: 14px;
  cursor: pointer;
}
.opt:hover, .opt.is-active { background: var(--signal-wash); }
.opt[aria-selected="true"] .opt-name::after {
  content: "Current"; margin-left: 8px;
  font-size: 11px; font-weight: 600; color: var(--signal);
}
.opt-star {
  height: 56px; text-align: center;
  font-size: 40px; line-height: 64px; color: var(--ink);
  overflow: hidden;
  opacity: 0; transition: opacity 160ms ease;
}
.opt-star.is-ready { opacity: 1; }
.opt-star.no-fade { transition: none; }
.opt-star.is-failed { color: var(--hint); }
.opt-name {
  font-size: 13px; color: var(--slate);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Phones: the picker becomes a bottom sheet. */
@media (max-width: 600px) {
  .picker {
    position: fixed; top: auto; left: 0; right: 0; bottom: 0;
    width: auto; height: 58vh;
    display: flex; flex-direction: column;
    border-radius: 14px 14px 0 0; border-bottom: 0;
  }
  .picker-scroll { height: auto; flex: 1; min-height: 0; }
  /* Room to scroll the password field above the sheet. */
  body.picker-open { padding-bottom: 58vh; }
}

/* ---- reverse CAPTCHA ----------------------------------------------------- */

.captcha {
  width: min(440px, calc(100vw - 32px));
  padding: 0; border: 0; border-radius: 12px;
  background: var(--card); color: var(--ink);
  box-shadow: 0 24px 64px rgba(24, 32, 44, 0.28);
}
.captcha::backdrop { background: rgba(24, 32, 44, 0.5); }

.captcha-head {
  display: flex; gap: 12px; align-items: center;
  padding: 16px 20px;
  background: var(--ink); color: #fff;
  border-radius: 12px 12px 0 0;
}
.captcha-icon { flex: none; }
.captcha-title { margin: 0; font-weight: 600; font-size: 17px; }
.captcha-desc { margin: 2px 0 0; font-size: 14px; color: #c9d0da; }

.captcha-body { padding: 20px; }
.captcha-prompt { margin: 0 0 12px; font-weight: 600; overflow-wrap: anywhere; }

.captcha-input {
  width: 100%; height: 44px; padding: 0 12px;
  border: 1px solid var(--rule); border-radius: var(--radius);
  font: 400 16px var(--ui); color: var(--ink);
}
.captcha-input.is-mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.captcha-input:focus { outline: 2px solid var(--signal); outline-offset: -1px; border-color: transparent; }

.captcha-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.captcha-tile {
  min-height: 72px; padding: 6px;
  border: 1px solid var(--rule); border-radius: 6px; background: var(--paper);
  font: 400 10px/1.35 ui-monospace, "SF Mono", Menlo, monospace; color: var(--ink);
  overflow-wrap: anywhere; cursor: pointer;
}
.captcha-tile[aria-pressed="true"] { border-color: var(--signal); background: var(--signal-wash); box-shadow: inset 0 0 0 1px var(--signal); }

.captcha-check {
  display: inline-flex; align-items: center; gap: 10px;
  min-height: 44px; padding: 0 14px;
  border: 1px solid var(--rule); border-radius: var(--radius); background: var(--paper);
  font-weight: 600; cursor: pointer;
}
.captcha-check input { width: 22px; height: 22px; margin: 0; }

.captcha-timer { height: 4px; margin-top: 16px; border-radius: 2px; background: var(--track); overflow: hidden; }
.captcha-timer-fill { height: 100%; background: var(--signal); transform-origin: left; }
.captcha[data-state="failed"] .captcha-timer-fill { background: var(--weak); }
.captcha[data-state="passed"] .captcha-timer-fill { background: var(--strong); }
@keyframes captcha-countdown { from { transform: scaleX(1); } to { transform: scaleX(0); } }
.captcha-timer-text { margin: 6px 0 0; font-size: 13px; color: var(--slate); }

.captcha-result:empty { display: none; }
.captcha-result { margin: 14px 0 0; padding: 10px 14px; border-radius: var(--radius); font-size: 14px; }
.captcha[data-state="failed"] .captcha-result { background: #fdf1ec; color: #7a2a08; }
.captcha[data-state="passed"] .captcha-result { background: #ebf5ef; color: #1d5235; font-weight: 600; }

.captcha-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.captcha-actions:empty { display: none; }
.captcha-primary, .captcha-secondary {
  min-height: 44px; padding: 0 16px;
  border-radius: var(--radius); font: 600 15px var(--ui); cursor: pointer;
}
.captcha-primary { border: 0; background: var(--signal); color: #fff; }
.captcha-secondary { border: 1px solid var(--rule); background: var(--card); color: var(--ink); }

@media (prefers-reduced-motion: reduce) {
  .captcha-timer-fill { animation: none !important; } /* the seconds-left text still counts down */
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
