/* MunichPortal — design system for autistic & ND users.
 *
 * Principles:
 *  - Calm, low-saturation palette; generous whitespace; no pure white/black glare.
 *  - Predictable, consistent layout. No animations, no parallax, no autoplay.
 *  - Readable: large base size, 1.6 line height, ~70ch measure, system fonts.
 *  - Color is never the only signal — every state has text.
 *  - Strong visible focus states; large tap targets.
 *  - Calm mode (html.calm) hides imagery and softens accents.
 */

:root {
  --bg: #f6f5f1;
  --surface: #fffefb;
  --surface-2: #efede6;
  --text: #33393b;
  --text-muted: #5f6a6e;
  --border: #d8d5cb;
  --accent: #3d6b6a;        /* calm teal */
  --accent-soft: #e3edec;
  --link: #2c5e75;
  --danger: #96442e;
  --focus: #8a5a2b;
  /* sensory levels: paired with text labels everywhere */
  --sense-0: #dcebdd;
  --sense-1: #e7ecd4;
  --sense-2: #f3e5c8;
  --sense-3: #f2d7c8;
  --radius: 10px;
  --space: 1rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #22262a;
    --surface: #2b3036;
    --surface-2: #333941;
    --text: #dcdfe2;
    --text-muted: #a3acb2;
    --border: #454d55;
    --accent: #7fb2b0;
    --accent-soft: #32403f;
    --link: #93c1d8;
    --danger: #e0937d;
    --focus: #d9a35c;
    --sense-0: #37493c;
    --sense-1: #45483a;
    --sense-2: #52483a;
    --sense-3: #55403a;
  }
}

* {
  box-sizing: border-box;
}

html {
  /* Respect users who set larger default font sizes. */
  font-size: 106.25%; /* 17px at browser default */
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.6;
}

/* No animations or transitions anywhere; motion is opt-in only, and we opt out entirely. */
*,
*::before,
*::after {
  animation: none !important;
  transition: none !important;
  scroll-behavior: auto !important;
}

.wrap {
  max-width: 62rem;
  margin: 0 auto;
  padding: 0 var(--space);
}

main.wrap {
  padding-top: 1.5rem;
  padding-bottom: 3rem;
  min-height: 70vh;
}

a {
  color: var(--link);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--surface);
  padding: 0.5rem 1rem;
  z-index: 10;
}
.skip-link:focus {
  left: 0.5rem;
  top: 0.5rem;
}

h1,
h2,
h3 {
  line-height: 1.25;
  margin: 1.6em 0 0.5em;
}
h1 {
  font-size: 1.8rem;
  margin-top: 0.5em;
}
h2 {
  font-size: 1.3rem;
}
h3 {
  font-size: 1.05rem;
}

p,
li {
  max-width: 70ch;
}

.muted {
  color: var(--text-muted);
}

/* --- header / footer ----------------------------------------------------- */

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
}
.site-title {
  font-weight: 700;
  font-size: 1.15rem;
  text-decoration: none;
  color: var(--text);
}
.main-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.1rem;
  list-style: none;
  margin: 0;
  padding: 0;
  align-items: center;
}
.main-nav a {
  color: var(--text);
  text-decoration: none;
  padding: 0.4rem 0.15rem;
  display: inline-block;
  border-bottom: 3px solid transparent;
}
.main-nav a:hover {
  border-bottom-color: var(--accent);
}
.main-nav a.nav-strong {
  font-weight: 700;
}

/* utility row: display preferences, language, logout — visually separate
   from the content navigation */
.util-row {
  border-top: 1px solid var(--border);
}
.util-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.1rem;
  list-style: none;
  margin: 0;
  padding: 0.35rem 0;
  align-items: center;
  font-size: 0.9rem;
}
.util-nav a {
  color: var(--text-muted);
}
.util-nav .calm-toggle {
  font-size: 0.9rem;
  padding: 0.25rem 0.6rem;
}
.util-nav .link-button {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 1.25rem 0 2rem;
}

.page-intro {
  font-size: 1.05rem;
  color: var(--text-muted);
  max-width: 65ch;
}

/* --- buttons & forms ------------------------------------------------------ */

.button {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.55rem 1.1rem;
  font-size: 1rem;
  cursor: pointer;
  text-decoration: none;
}
.button:hover {
  filter: brightness(1.08);
}
.button-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.button-small {
  padding: 0.25rem 0.6rem;
  font-size: 0.9rem;
}
.button.danger {
  background: var(--danger);
  border-color: var(--danger);
}
.link-button {
  background: none;
  border: none;
  color: var(--link);
  text-decoration: underline;
  cursor: pointer;
  font: inherit;
  padding: 0.25rem;
}
.link-button.danger {
  color: var(--danger);
}
.inline-form {
  display: inline;
  margin-left: 0.5rem;
}

.calm-toggle {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.35rem 0.7rem;
  cursor: pointer;
  font: inherit;
  color: var(--text);
}
.calm-toggle[aria-pressed='true'] {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.calm-toggle[aria-pressed='true']::after {
  content: ' ✓';
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.75rem;
}
input,
select,
textarea {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.5rem 0.6rem;
  font: inherit;
  font-weight: 400;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}
label.checkbox {
  font-weight: 400;
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
label.checkbox input {
  display: inline-block;
  width: 1.2rem;
  height: 1.2rem;
  margin: 0;
}
.checkbox-fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
}
.checkbox-fieldset legend {
  font-weight: 600;
  padding: 0 0.3rem;
}

.stacked-form {
  max-width: 46rem;
}
.narrow {
  max-width: 30rem;
}
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: 0.75rem;
  align-items: end;
}
fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 0 0 1.25rem;
  padding: 1rem;
}
legend {
  font-weight: 700;
  padding: 0 0.4rem;
}

.error {
  background: var(--sense-3);
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  padding: 0.6rem 0.9rem;
}

/* --- filters --------------------------------------------------------------- */

.filter-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin: 1rem 0;
}
.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 0.6rem 1rem;
}
.filter-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.5rem;
}
.result-count {
  font-weight: 600;
}

/* --- cards ------------------------------------------------------------------ */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
  gap: 1rem;
  margin: 1rem 0;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
}
.card h3 {
  margin: 0.35rem 0;
}
.card h3 a {
  color: var(--text);
  text-decoration: none;
}
.card h3 a:hover {
  text-decoration: underline;
}
.card-head {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.3rem;
  font-size: 0.85rem;
}
.kind-badge {
  color: var(--text-muted);
}
.date-badge {
  background: var(--accent-soft);
  border-radius: 6px;
  padding: 0.1rem 0.5rem;
  font-weight: 600;
}
.summary {
  margin: 0.3rem 0;
}
.meta {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0.3rem 0;
}

/* --- sensory pills & panel --------------------------------------------------- */

.pill-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0;
  margin: 0.5rem 0 0;
}
.pill {
  font-size: 0.82rem;
  border-radius: 999px;
  padding: 0.15rem 0.65rem;
  border: 1px solid var(--border);
  background: var(--surface-2);
  max-width: none;
}
.pill.sensory-0 { background: var(--sense-0); }
.pill.sensory-1 { background: var(--sense-1); }
.pill.sensory-2 { background: var(--sense-2); }
.pill.sensory-3 { background: var(--sense-3); }
.pill-support {
  background: var(--accent-soft);
}
/* personal comfort-fit badges (text always present, never color alone) */
.pill.fit-ok {
  display: inline-block;
  background: var(--accent-soft);
  border-color: var(--accent);
  font-weight: 600;
}
.pill.fit-over {
  display: inline-block;
  background: var(--sense-3);
  font-weight: 600;
}
.pill.fit-unknown {
  display: inline-block;
  background: var(--surface-2);
}
.card .pill.fit-ok,
.card .pill.fit-over,
.card .pill.fit-unknown {
  margin: 0.35rem 0 0;
}
.forme-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.me-list {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}
.digest-preview {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  white-space: pre-wrap;
  overflow-x: auto;
  font-size: 0.9rem;
}

.chip-row {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0;
  margin: 0.75rem 0;
}
.chip {
  display: inline-block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.3rem 0.9rem;
  text-decoration: none;
  color: var(--text);
}
.chip-active {
  background: var(--accent-soft);
  border-color: var(--accent);
  font-weight: 700;
}

.warn-box {
  background: var(--sense-3);
  border: 1px solid var(--danger);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
}
.checklist {
  list-style: none;
  padding: 0;
}
.checklist li {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  padding: 0.35rem 0;
}
.checklist input {
  width: 1.3rem;
  height: 1.3rem;
  margin: 0;
}

@media print {
  .site-header,
  .site-footer,
  .no-print {
    display: none !important;
  }
  body {
    background: #fff;
    color: #000;
  }
  .panel {
    border: 1px solid #999;
    break-inside: avoid;
  }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin: 1.25rem 0;
}
.panel h2 {
  margin-top: 0.25rem;
}

.sensory-grid {
  margin: 0;
}
.sensory-row {
  display: grid;
  grid-template-columns: 11rem 1fr;
  gap: 0.5rem;
  padding: 0.35rem 0;
  border-bottom: 1px dashed var(--border);
}
.sensory-row dt {
  font-weight: 600;
}
.sensory-row dd {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.meter {
  display: inline-flex;
  gap: 3px;
}
.meter .dot {
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-2);
}
.meter-0 .dot.on { background: var(--sense-0); border-color: var(--text-muted); }
.meter-1 .dot.on { background: var(--sense-1); border-color: var(--text-muted); }
.meter-2 .dot.on { background: var(--sense-2); border-color: var(--text-muted); }
.meter-3 .dot.on { background: var(--sense-3); border-color: var(--text-muted); }
.sensory-value {
  font-weight: 600;
}
.support-list {
  list-style: none;
  padding: 0;
}
.notes {
  background: var(--surface-2);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
}

/* --- detail page --------------------------------------------------------------- */

.breadcrumb {
  font-size: 0.9rem;
  color: var(--text-muted);
}
.lede {
  font-size: 1.1rem;
}
.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 0.6rem 1.5rem;
  margin: 0;
}
.facts dt {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.facts dd {
  margin: 0;
}
.links a {
  margin-right: 1rem;
}
.date-list {
  list-style: none;
  padding: 0;
}
.date-list li {
  padding: 0.25rem 0;
}

.image-list {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
  gap: 1rem;
  padding: 0;
}
.image-list img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  display: block;
}
figure {
  margin: 0;
}
figcaption {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* --- home ------------------------------------------------------------------------ */

.category-grid {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
  gap: 0.75rem;
  padding: 0;
}
.category-tile {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  text-decoration: none;
  color: var(--text);
  height: 100%;
}
.category-tile:hover {
  border-color: var(--accent);
}
.category-icon {
  font-size: 1.4rem;
  display: block;
}
.category-name {
  font-weight: 700;
  display: block;
}
.category-desc {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.combo-list {
  padding-left: 1.2rem;
}
.combo-cards {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
  gap: 1rem;
}
.combo-cards h2 {
  font-size: 1.1rem;
  margin: 0 0 0.3rem;
}

.day-heading {
  border-bottom: 2px solid var(--accent);
  padding-bottom: 0.25rem;
}

.combo-steps {
  list-style: none;
  padding: 0;
  margin: 1rem 0;
}
.combo-step {
  display: grid;
  grid-template-columns: 2.4rem 1fr;
  gap: 0.9rem;
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--border);
}
.step-number {
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}
.step-body h3 {
  margin: 0 0 0.25rem;
}

.area-list,
.sub-areas {
  list-style: none;
  padding: 0;
}
.area-list > li {
  margin-bottom: 1rem;
}
.sub-areas {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.2rem;
}

/* --- admin ----------------------------------------------------------------------- */

.admin-nav {
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 0.6rem 1rem;
  margin-bottom: 1rem;
}
.admin-nav a {
  margin-right: 1rem;
}
.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.admin-table th,
.admin-table td {
  text-align: left;
  padding: 0.5rem 0.7rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.admin-table input,
.admin-table select {
  margin-top: 0;
}
.token-reveal code {
  user-select: all;
  word-break: break-all;
}
.prose img {
  max-width: 100%;
  height: auto;
}

/* --- calm mode --------------------------------------------------------------------- */
/* Hides imagery and decorative color for a lower-stimulation experience. */

html.calm img,
html.calm .gallery {
  display: none !important;
}
html.calm .category-icon {
  display: none;
}
html.calm .date-badge,
html.calm .pill {
  background: var(--surface-2) !important;
}
html.calm body {
  background: var(--surface);
}

/* --- large text mode ---------------------------------------------------------------- */

html.large {
  font-size: 131.25%; /* 21px at browser default */
}
html.large body {
  line-height: 1.7;
}

@media (max-width: 40rem) {
  .sensory-row {
    grid-template-columns: 1fr;
    gap: 0.1rem;
  }
  html {
    font-size: 100%;
  }
}
