/*
 * Password Generator — styles
 * Light / dark theme follows the system setting (prefers-color-scheme),
 * or can be forced with data-theme="light" | "dark" on <html>.
 *
 * @license MIT
 */

/* ---------- Theme ---------- */

:root {
  color-scheme: light;
  --bg: #eef2f6;
  --surface: #ffffff;
  --field: #f6f8fb;
  --ink: #0f1b2d;
  --muted: #5b6b80;
  --line: #d5dde7;
  --primary: #1d5bd8;
  --primary-ink: #ffffff;
  --primary-soft: #e6eefc;
  --ok: #157347;
  --error: #c0322b;
  --shadow: 0 1px 2px rgba(15, 27, 45, .06), 0 8px 24px -12px rgba(15, 27, 45, .18);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1320;
  --surface: #121d2e;
  --field: #0e1726;
  --ink: #e6ecf3;
  --muted: #93a3b8;
  --line: #26354b;
  --primary: #4b83f0;
  --primary-soft: #1a2c4b;
  --ok: #5fcf95;
  --error: #ff8079;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -12px rgba(0, 0, 0, .6);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b1320;
    --surface: #121d2e;
    --field: #0e1726;
    --ink: #e6ecf3;
    --muted: #93a3b8;
    --line: #26354b;
    --primary: #4b83f0;
    --primary-soft: #1a2c4b;
    --ok: #5fcf95;
    --error: #ff8079;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -12px rgba(0, 0, 0, .6);
  }
}

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 var(--font);
  overflow-x: clip;
}

.page {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: clamp(24px, 5vw, 56px) max(4vw, 16px);
}

/* ---------- Header ---------- */

h1 {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0 0 6px;
  font-size: clamp(26px, 5vw, 34px);
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: -.01em;
}
h1::before { /* app icon */
  content: "";
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--primary) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='8' cy='12' r='4'/%3E%3Cpath d='M12 12h9M18 12v3M21 12v2'/%3E%3C/svg%3E") center / 26px no-repeat;
}
.subtitle { margin: 0 0 24px; color: var(--muted); }

/* ---------- Card ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  --pad: clamp(18px, 4vw, 28px);
  padding: var(--pad);
}

/* ---------- Password field ---------- */

.password-field { position: relative; margin: 0 0 16px; }

.password {
  display: flex;
  align-items: center;
  min-height: 76px;
  margin: 0;
  padding: 16px 62px 16px 18px; /* room for the copy icon */
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 10px;
  font: 600 clamp(18px, 4.6vw, 24px)/1.35 var(--mono);
  word-break: break-all;
  user-select: all;
}
.password.is-empty { color: var(--muted); font: 400 15px/1.4 var(--font); word-break: normal; user-select: none; }
.password.is-fresh { animation: fade .25s ease-out; }
@keyframes fade { from { opacity: .3; } to { opacity: 1; } }

/* ---------- Buttons ---------- */

.actions { display: flex; flex-direction: column; gap: 10px; }

button {
  min-height: 46px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: 8px;
  font: 600 15px var(--font);
  cursor: pointer;
  transition: background-color .15s, border-color .15s;
}
button:disabled { opacity: .45; cursor: not-allowed; }
button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--primary) 45%, transparent);
  outline-offset: 2px;
}

.btn-primary { width: 100%; background: var(--primary); color: var(--primary-ink); }
.btn-primary:hover:not(:disabled) { background: color-mix(in srgb, var(--primary) 88%, black); }
.btn-secondary { width: 100%; background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-secondary:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }

/* Copy icon inside the password field */
.btn-icon {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  min-height: 0;
  padding: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
}
.btn-icon:hover:not(:disabled) { background: var(--primary-soft); color: var(--primary); }
.btn-icon:disabled { visibility: hidden; }
.btn-icon .icon-done { display: none; }
.btn-icon.is-done { color: var(--ok); }
.btn-icon.is-done .icon-copy { display: none; }
.btn-icon.is-done .icon-done { display: block; }

.status { min-height: 22px; margin: 10px 0 0; font-size: 14px; color: var(--ok); }
.status.is-error { color: var(--error); }

/* ---------- Chrome extension ---------- */

.extension { margin-top: 28px; }
.extension h2 { margin: 0 0 4px; font-size: 18px; }
.extension p { margin: 0 0 12px; color: var(--muted); }
.btn-link {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font: 600 15px var(--font);
  text-decoration: none;
}
.btn-link:hover { border-color: var(--primary); color: var(--primary); }
.btn-link:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 45%, transparent); outline-offset: 2px; }
.install { margin-top: 12px; font-size: 15px; }
.install summary { cursor: pointer; color: var(--primary); font-weight: 600; }
.install ol { margin: 8px 0 0; padding-left: 22px; }
.install li { margin: 4px 0; }
.install code { font: 14px var(--mono); }

/* ---------- Options ---------- */

.options {
  margin: 12px calc(-1 * var(--pad)) calc(-1 * var(--pad));
  border-top: 1px solid var(--line);
}
.options-body { padding: 4px var(--pad) var(--pad); }
.options-title { font-size: 16px; }

/* Collapsible panel (native <details>, closed by default) */
.options > summary {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 12px;
  min-height: 52px;
  padding: 14px 36px 14px 0;
  list-style: none;
  cursor: pointer;
  user-select: none;
}
.options > summary::-webkit-details-marker { display: none; }
.options > summary::after { /* chevron */
  content: "";
  position: absolute;
  top: 50%;
  right: 8px;
  width: 9px;
  height: 9px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-75%) rotate(45deg);
  transition: transform .2s;
}
.options[open] > summary::after { transform: translateY(-25%) rotate(-135deg); }
.options > summary:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 45%, transparent); outline-offset: 2px; border-radius: 6px; }
.options-title { font-weight: 600; }
.options-summary { color: var(--muted); font-size: 14px; }
.options[open] .options-summary { display: none; }
.options-body > fieldset:first-child { margin-top: 0; }
.options > summary { padding-left: var(--pad); padding-right: calc(var(--pad) + 28px); border-radius: 0 0 14px 14px; }
.options[open] > summary { border-radius: 0; }
.options > summary::after { right: calc(var(--pad) + 6px); }
.options > summary:hover { background: var(--field); }
.options > summary:focus-visible { outline-offset: -3px; }

fieldset { margin: 16px 0 0; padding: 0; border: 0; }
legend { padding: 0 0 8px; font-size: 14px; font-weight: 600; color: var(--muted); }

/* Segmented control */
.chips {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.chip {
  flex: 1 1 0;
  min-height: 42px;
  padding: 0 4px;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  background: var(--surface);
  color: var(--ink);
  font: 600 15px var(--mono);
}
.chip:last-child { border-right: 0; }
.chip:hover { background: var(--primary-soft); }
.chip[aria-checked="true"] { background: var(--primary); color: var(--primary-ink); }
.chip:focus-visible { outline-offset: -3px; }

.select-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 12px 0 0; font-size: 15px; }
select {
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font: 500 15px var(--font);
  cursor: pointer;
}

/* Checkbox tiles */
.checks { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px; }
.checks label, .check-extra {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
}
.checks label:has(input:checked), .check-extra:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.checks input, .check-extra input { flex: none; width: 18px; height: 18px; accent-color: var(--primary); }
.sample { margin-left: auto; flex: none; white-space: nowrap; color: var(--muted); font: 500 13px var(--mono); }
.check-extra { margin: 12px 0 0; }

/* Option whose sample (full list of special characters) goes on its own line */
.checks .check-wide { flex-wrap: wrap; padding-block: 10px; }
.checks .check-wide .sample { flex: 1 1 100%; margin-left: 28px; white-space: normal; line-height: 1.6; }
.checks .check-wide { grid-column: 1 / -1; }


.hint { margin: 8px 0 0; color: var(--muted); font-size: 13px; }

/* ---------- Footer ---------- */

.footer { margin: 20px 0 0; color: var(--muted); font-size: 13px; text-align: center; }

/* ---------- Utilities ---------- */

.visually-hidden {
  position: fixed !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  opacity: 0;
}

@media (prefers-reduced-motion: reduce) {
  .password.is-fresh { animation: none; }
  button { transition: none; }
  .options > summary::after { transition: none; }
}
