/* =====================================================
   STYLE: dark green + beige, modern and elegant
   Change the colours and fonts in :root below and the
   whole page updates.
   ===================================================== */

:root {
  --beige: #e9e4d8; /* page background */
  --beige-light: #f4f1e9; /* input boxes */
  --green: #1f3b2d; /* main colour */
  --green-hover: #2e5642; /* buttons when hovered */
  --muted: #4b5e52; /* small, quieter text */
  --line: rgba(31, 59, 45, 0.28); /* thin borders */
  --weak: #9b4a3c;
  --fair: #b8892e;

  --font-display: "Instrument Serif", "Times New Roman", serif;
  --font-script: "Pinyon Script", cursive;
  --font-body: "Inter", system-ui, sans-serif;
}

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

body {
  margin: 0;
  padding: 2rem 1rem 3rem;
  background: var(--beige);
  color: var(--green);
  font-family: var(--font-body);
  line-height: 1.5;
}

.app {
  max-width: 560px;
  margin: 0 auto;
}

/* Makes the "hidden" attribute always work (the tab panels rely on this) */
[hidden] {
  display: none !important;
}

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

/* ---------- HEADING: tall serif + script word on top ---------- */
.title {
  margin: 0 0 1.25rem;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(3rem, 13vw, 4.75rem);
  line-height: 0.9;
  text-transform: uppercase;
  text-align: center;
}
.title .script {
  display: block;
  margin-top: -0.3em; /* pulls the script up so it overlaps the serif */
  padding-right: 0.5rem;
  text-align: right;
  font-family: var(--font-script);
  font-size: 0.7em;
  text-transform: none;
  line-height: 1;
}

.privacy,
.tip {
  color: var(--muted);
  font-size: 0.875rem;
  text-align: center;
}

/* ---------- TABS: pill-shaped switch ---------- */
.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin: 1.5rem 0 1rem;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
}
.tab {
  padding: 0.65rem 0.5rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--green);
  font: 500 0.95rem var(--font-body);
  cursor: pointer;
}
.tab.is-active {
  background: var(--green);
  color: var(--beige);
}

/* ---------- OPTIONS PANEL ---------- */
.panel {
  margin-bottom: 1.25rem;
  padding: 1.25rem;
  border: 1px solid var(--line);
  border-radius: 14px;
}
.field {
  margin: 0 0 1.1rem;
  padding: 0;
  border: 0;
}
.field:last-child {
  margin-bottom: 0;
}
.field > label,
legend {
  display: block;
  margin-bottom: 0.4rem;
  font-weight: 500;
}
legend {
  padding: 0;
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 400;
}

fieldset label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.25rem 0;
}

input[type="range"],
input[type="checkbox"] {
  accent-color: var(--green);
}
input[type="range"] {
  width: 100%;
}
input[type="checkbox"] {
  width: 1.1rem;
  height: 1.1rem;
}

input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--beige-light);
  color: var(--green);
  font: 1rem var(--font-body);
}

/* ---------- BUTTONS ---------- */
.btn {
  width: 100%;
  padding: 0.85rem 1rem;
  border: 1px solid var(--green);
  border-radius: 999px;
  background: var(--green);
  color: var(--beige);
  font: 500 1rem var(--font-body);
  cursor: pointer;
  transition: background 0.15s;
}
.btn:hover {
  background: var(--green-hover);
}

/* Smaller outlined buttons next to the result */
.btn--small {
  width: auto;
  padding: 0.6rem 1.1rem;
  background: transparent;
  color: var(--green);
}
.btn--small:hover {
  background: var(--green);
  color: var(--beige);
}

/* ---------- RESULT + STRENGTH ---------- */
.result-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 1.25rem;
}
#result {
  flex: 1;
  min-width: 0;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  letter-spacing: 0.02em;
}

.message {
  min-height: 1.5em;
  margin: 0.6rem 0;
  font-size: 0.9rem;
}

.strength {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
}
#strength-meter {
  flex: 1;
  height: 0.7rem;
}
#strength-label {
  min-width: 11rem;
  text-align: right;
}

/* Meter colours: red = weak, amber = fair, green = strong */
#strength-meter {
  -webkit-appearance: none;
  appearance: none;
  background: none;
  border: 0;
}
#strength-meter::-webkit-meter-bar {
  background: rgba(31, 59, 45, 0.12);
  border: 0;
  border-radius: 999px;
}
#strength-meter::-webkit-meter-even-less-good-value {
  background: var(--weak);
  border-radius: 999px;
}
#strength-meter::-webkit-meter-suboptimum-value {
  background: var(--fair);
  border-radius: 999px;
}
#strength-meter::-webkit-meter-optimum-value {
  background: var(--green);
  border-radius: 999px;
}
/* Firefox uses different names */
#strength-meter:-moz-meter-sub-sub-optimum::-moz-meter-bar {
  background: var(--weak);
}
#strength-meter:-moz-meter-sub-optimum::-moz-meter-bar {
  background: var(--fair);
}
#strength-meter:-moz-meter-optimum::-moz-meter-bar {
  background: var(--green);
}

/* ---------- ACCESSIBILITY + MOBILE ---------- */
button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  .btn {
    transition: none;
  }
}

@media (max-width: 480px) {
  .result-row {
    flex-wrap: wrap;
  }
  #result {
    flex-basis: 100%;
  }
  .btn--small {
    flex: 1;
  }
  #strength-label {
    min-width: 0;
  }
  .strength {
    flex-wrap: wrap;
  }
}
