/*
 * Otthon components — one style per UI element, built only from tokens.css.
 * Load tokens.css first, then this file, then the project's own CSS. Copy it into
 * the project like tokens.css (byte-identical; re-copy to update).
 *
 * Every class starts with "o-" so it never collides with a project's own names.
 * Modifiers: "o-btn o-btn--primary". States use ARIA/HTML attributes
 * (aria-current, aria-selected, aria-checked, aria-pressed, aria-invalid, disabled).
 * Markup for each element: reference/index.html (live page:
 * https://artifacts.vpn.orsos.dev/otthon-komponensek/).
 *
 * Look: flat surfaces (1 px --line, no gradients, no drop shadows), Manrope,
 * cornflower full stop after brand and page titles, --ui for interactive outlines.
 */

/* ---------- base (opt-in: <body class="o-base">) ---------- */

.o-base {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 var(--text-m) / var(--leading) var(--font);
  -webkit-font-smoothing: antialiased;
  text-size-adjust: 100%;
}
:where(.o-base) *,
:where(.o-base) *::before,
:where(.o-base) *::after { box-sizing: border-box; }
/* :where() keeps these at element weight, so every o- class below still sets its own colour */
:where(.o-base) :focus-visible { outline: 2px solid var(--ui); outline-offset: 2px; }
:where(.o-base) a { color: var(--accent-ink); text-underline-offset: 0.2em; }

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

.o-shell {            /* centred page column with a 16 px phone gutter */
  width: min(100% - 2 * var(--space-4), 1040px);
  margin-inline: auto;
}
.o-shell--narrow { width: min(100% - 2 * var(--space-4), 760px); }
.o-stack { display: flex; flex-direction: column; gap: var(--space-4); }
.o-stack--s { gap: var(--space-2); }
.o-stack--l { gap: var(--space-6); }
.o-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
.o-row--between { justify-content: space-between; }
.o-grid {             /* responsive cards: as many 260 px+ columns as fit */
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr));
  gap: var(--space-4);
}
.o-divider { border: 0; border-top: 1px solid var(--line); margin: 0; }

/* ---------- header and brand ---------- */

.o-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3) var(--space-4);
  padding-block: var(--space-5) var(--space-4);
}
.o-brand {            /* project name; ends in a cornflower full stop */
  color: var(--ink);
  font-size: 1.2rem;
  font-weight: var(--display-weight);
  letter-spacing: var(--display-tracking);
  line-height: 1;
  text-decoration: none;
}
.o-brand--dot::after,
.o-title--dot::after { content: "."; color: var(--accent); }
.o-dot { color: var(--accent); }   /* a dot inside a name: orsos<span class="o-dot">.</span>hu */
.o-header__actions { display: flex; align-items: center; gap: var(--space-2); }

/* ---------- type ---------- */

.o-display,
.o-title,
.o-heading { margin: 0; color: var(--ink); text-wrap: balance; }
.o-display {
  font-size: var(--text-display);
  font-weight: var(--display-weight);
  letter-spacing: var(--display-tracking);
  line-height: 1.02;
}
.o-title {
  font-size: var(--text-xl);
  font-weight: var(--display-weight);
  letter-spacing: var(--display-tracking);
  line-height: var(--leading-tight);
}
.o-heading { font-size: var(--text-l); font-weight: 700; letter-spacing: -0.02em; line-height: 1.25; }
.o-lead { margin: 0; color: var(--muted); font-size: 1.15rem; font-weight: 500; max-width: 48rem; }
.o-muted { color: var(--muted); }
.o-meta { color: var(--muted); font-size: var(--text-xs); }
.o-eyebrow {
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.o-num { font-variant-numeric: tabular-nums; }
.o-code {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  font: 0.9em ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  padding: 0.05em 0.35em;
}
.o-link { color: var(--accent-ink); text-underline-offset: 0.2em; }
.o-link:hover { text-decoration-thickness: 2px; }

/* ---------- surfaces ---------- */

.o-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  background: var(--surface);
  padding: clamp(var(--space-4), 4vw, var(--space-6));
}
.o-card--inset { border-radius: var(--radius-m); background: var(--surface-2); padding: var(--space-3) var(--space-4); }
.o-card--compact { padding: var(--space-4); }
a.o-card,
.o-card--link {
  display: block;
  color: inherit;
  text-decoration: none;
  transition: border-color 160ms ease;
}
a.o-card:hover,
.o-card--link:hover { border-color: var(--ui); }

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

.o-btn {              /* default = secondary: outline on the page colour */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--touch);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: transparent;
  color: var(--ink);
  font: 600 var(--text-s) / 1.2 var(--font);
  padding: 0 var(--space-4);
  text-decoration: none;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
}
.o-btn:hover { background: var(--surface-2); }
.o-btn--primary { border-color: transparent; background: var(--fill); color: var(--on-fill); font-weight: 700; }  /* soft tint, blue text */
.o-btn--primary:hover { background: var(--fill-hover); }
.o-btn--danger { border-color: color-mix(in srgb, var(--bad) 35%, transparent); background: color-mix(in srgb, var(--bad) 10%, var(--surface)); color: var(--bad); font-weight: 700; }
.o-btn--danger:hover { background: color-mix(in srgb, var(--bad) 16%, var(--surface)); }
.o-btn--ghost { border-color: transparent; background: transparent; color: var(--accent-ink); }
.o-btn--ghost:hover { border-color: transparent; background: color-mix(in srgb, var(--accent) 14%, transparent); }
.o-btn--s { min-height: 32px; padding: 0 var(--space-3); border-radius: calc(var(--radius-s) - 2px); }
.o-btn--icon {        /* round, icon only; give it an aria-label */
  width: var(--touch);
  padding: 0;
  border-radius: var(--radius-pill);
}
.o-btn:disabled,
.o-btn[aria-disabled="true"] {
  border-color: var(--line);
  background: transparent;
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.7;
}
.o-btn svg { width: 1.15em; height: 1.15em; flex: none; }

/* ---------- tabs and segmented navigation ---------- */

.o-tabs {             /* pill track; children are <a class="o-tab"> or <button class="o-tab"> */
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  background: var(--surface-2);
  padding: 4px;
}
.o-tabs--fill { display: grid; grid-auto-columns: 1fr; grid-auto-flow: column; }
.o-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: calc(var(--radius-m) - 4px);
  background: transparent;
  color: var(--muted);
  font: 600 var(--text-s) / 1.2 var(--font);
  padding: 0 var(--space-4);
  text-decoration: none;
  cursor: pointer;
}
.o-tab:hover { color: var(--ink); }
.o-tab[aria-current="page"],
.o-tab[aria-selected="true"] {
  border-color: var(--ui);
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
  color: var(--accent-ink);
}

/* bottom navigation bar (phone / HA) */
.o-navbar {
  display: grid;
  grid-auto-columns: 1fr;
  grid-auto-flow: column;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  background: var(--surface);
  padding: 5px;
}
.o-navbar a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  border: 1px solid transparent;
  border-radius: calc(var(--radius-l) - 6px);
  color: var(--muted);
  font-size: var(--text-xs);
  padding: 6px 0;
  text-decoration: none;
}
.o-navbar a[aria-current="page"] {
  border-color: var(--ui);
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
  color: var(--accent-ink);
}
.o-navbar svg { width: 20px; height: 20px; }

/* ---------- status ---------- */

.o-pill {             /* status: dot + label */
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--ink);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1.2;
  padding: 5px 12px;
  white-space: nowrap;
}
.o-pill::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  flex: none;
}
.o-pill--warn::before { background: var(--warn); }
.o-pill--bad { border-color: color-mix(in srgb, var(--bad) 45%, transparent); color: var(--bad); }
.o-pill--bad::before { background: var(--bad); }
.o-pill--off { color: var(--muted); }
.o-pill--off::before { background: var(--muted); }
.o-pill--plain::before { content: none; }  /* tag/label without status */

.o-notice {           /* inline message; role="status" or role="alert" */
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  border: 1px solid var(--line);
  border-left: 4px solid var(--ui);
  border-radius: var(--radius-m);
  background: var(--surface);
  color: var(--ink);
  padding: var(--space-3) var(--space-4);
}
.o-notice--ok { border-left-color: var(--ok); }
.o-notice--warn { border-left-color: var(--warn); }
.o-notice--bad { border-left-color: var(--bad); }
.o-notice > :first-child { margin-top: 0; }
.o-notice strong { font-weight: 700; }

.o-empty {            /* nothing to show yet: sentence + one action */
  display: grid;
  justify-items: center;
  gap: var(--space-3);
  border: 1px dashed color-mix(in srgb, var(--ink) 22%, transparent);
  border-radius: var(--radius-l);
  color: var(--muted);
  padding: var(--space-6) var(--space-4);
  text-align: center;
}
.o-empty strong { color: var(--ink); font-size: var(--text-l); }

/* ---------- data ---------- */

.o-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: var(--space-3); }
.o-stat {
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  background: var(--surface-2);
  padding: var(--space-3) var(--space-4);
}
.o-stat b {
  display: block;
  font-size: 1.5rem;
  font-weight: var(--display-weight);
  letter-spacing: var(--display-tracking);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.o-stat span { color: var(--muted); font-size: var(--text-s); }
.o-stat--bad b { color: var(--bad); }
.o-stat--warn b { color: var(--warn); }

.o-list { margin: 0; padding: 0; list-style: none; }
.o-list > li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-3);
  border-top: 1px solid var(--line);
  padding: var(--space-3) 0;
}
.o-list > li:first-child { border-top: 0; }
.o-list__main { min-width: 0; flex: 1 1 12rem; overflow-wrap: anywhere; }
.o-list__title { font-weight: 600; }

.o-table-wrap { overflow-x: auto; }  /* wrap every table: phones scroll the table, not the page */
.o-table { width: 100%; border-collapse: collapse; font-size: var(--text-s); }
.o-table th,
.o-table td { border-bottom: 1px solid var(--line); padding: var(--space-2) var(--space-3); text-align: left; vertical-align: top; }
.o-table th { color: var(--muted); font-size: var(--text-xs); font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.o-table tbody tr:hover { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.o-table .o-num,
.o-table td.num,
.o-table th.num { font-variant-numeric: tabular-nums; text-align: right; }

.o-bar {              /* meter/progress: <div class="o-bar"><span style="width:62%"></span></div> */
  height: 8px;
  overflow: hidden;
  border-radius: var(--radius-pill);
  background: var(--track);
}
.o-bar > span { display: block; height: 100%; border-radius: inherit; background: var(--ui); }
.o-bar--ok > span { background: var(--ok); }
.o-bar--warn > span { background: var(--warn); }
.o-bar--bad > span { background: var(--bad); }

/* ---------- forms ---------- */

.o-field { display: grid; gap: 6px; }
.o-label { color: var(--ink); font-size: var(--text-s); font-weight: 600; }
.o-hint { color: var(--muted); font-size: var(--text-xs); }
.o-error { color: var(--bad); font-size: var(--text-xs); font-weight: 600; }
.o-input,
.o-select,
.o-textarea {
  width: 100%;
  min-height: var(--touch);
  border: 1px solid color-mix(in srgb, var(--ink) 22%, transparent);
  border-radius: var(--radius-s);
  background: var(--surface);
  color: var(--ink);
  font: 400 var(--text-m) / 1.4 var(--font);   /* 16 px: no zoom on iOS focus */
  padding: 10px var(--space-3);
}
.o-textarea { min-height: 6rem; resize: vertical; }
.o-select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-repeat: no-repeat;
  background-size: 5px 5px;
  padding-right: 36px;
}
.o-input::placeholder,
.o-textarea::placeholder { color: var(--muted); opacity: 1; }
.o-input:hover,
.o-select:hover,
.o-textarea:hover { border-color: color-mix(in srgb, var(--ui) 60%, transparent); }
.o-input:focus-visible,
.o-select:focus-visible,
.o-textarea:focus-visible { border-color: var(--ui); outline: 2px solid var(--ui); outline-offset: 0; }
.o-input[aria-invalid="true"],
.o-select[aria-invalid="true"],
.o-textarea[aria-invalid="true"] { border-color: var(--bad); }
.o-input:disabled,
.o-select:disabled,
.o-textarea:disabled { background: var(--surface-2); color: var(--muted); cursor: not-allowed; }

.o-check {            /* <label class="o-check"><input type="checkbox|radio"> Text</label> */
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--touch);
  color: var(--ink);
  cursor: pointer;
}
.o-check input { width: 18px; height: 18px; margin: 0; accent-color: var(--ui); }

.o-switch {           /* <button class="o-switch" role="switch" aria-checked="false" aria-label="…"> */
  position: relative;
  width: 48px;
  height: 28px;
  flex: none;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--track);
  cursor: pointer;
  padding: 0;
  transition: background 150ms ease;
}
.o-switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--line);
  transition: transform 150ms ease;
}
.o-switch[aria-checked="true"] { border-color: transparent; background: var(--ui); }
.o-switch[aria-checked="true"]::after { background: var(--surface); box-shadow: none; transform: translateX(20px); }

.o-power {            /* round on/off button for devices: aria-pressed */
  display: grid;
  width: 46px;
  height: 46px;
  flex: none;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
  cursor: pointer;
}
.o-power:hover { border-color: var(--ui); }
.o-power[aria-pressed="true"] { border-color: var(--toggle-on-line); background: var(--toggle-on-bg); color: var(--toggle-on-fg); }
.o-power svg { width: 20px; height: 20px; }

.o-range { width: 100%; min-height: var(--touch); margin: 0; accent-color: var(--ui); cursor: pointer; }

/* ---------- dialog ---------- */

.o-dialog {           /* <dialog class="o-dialog"> opened with showModal() */
  width: min(100% - 2 * var(--space-4), 480px);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  background: var(--surface);
  color: var(--ink);
  padding: var(--space-5);
}
.o-dialog::backdrop { background: color-mix(in srgb, #000 45%, transparent); }
.o-dialog__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-5); }

/* ---------- TV / remote tiles ---------- */

.o-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(160px, 100%), 1fr)); gap: var(--space-3); }
.o-tile {
  display: flex;
  aspect-ratio: 16 / 10;
  align-items: flex-end;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  background: var(--surface-2);
  color: var(--ink);
  font-weight: 600;
  padding: var(--space-2) var(--space-3);
  text-decoration: none;
  cursor: pointer;
}
.o-tile:hover { border-color: var(--ui); }
.o-tile:focus-visible { outline: 3px solid var(--ui); outline-offset: 3px; background: var(--surface); }

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

.o-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: var(--text-s);
  padding-block: var(--space-4);
}

@media (prefers-reduced-motion: reduce) {
  .o-btn, .o-switch, .o-switch::after, .o-card--link, a.o-card { transition: none; }
}
