/* Loople themes and shared components.
 *
 * One source of truth for the browser: three palettes (light / dark /
 * greige) and one geometry.  A theme changes only token values — radius,
 * spacing, type and layout stay identical, so switching never moves content.
 *
 * Loaded after every service stylesheet; the vendored copy lives in each
 * service's static directory.  Edit only loople.shared/dist/loople-theme.css.
 */

/* Light — the base palette (the former "design 4.0"). */
:root,
html[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f7f9;
  --bg-soft: #eef1f6;
  --card-bg: #ffffff;
  --card: var(--card-bg);
  --panel: var(--card-bg);
  --bg-elevated: var(--card-bg);
  --panel-2: #f6f7f9;
  --text: #16181d;
  --ink: var(--text);
  --muted: #626976;
  --line: #e2e5ea;
  --border: var(--line);
  --chip: #eef1f6;
  --accent: #2f5bea;
  --accent-strong: #2447c9;
  --accent-soft: rgba(47, 91, 234, 0.12);
  --on-accent: #ffffff;
  --accent-ink: var(--on-accent);
  --header-bg: rgba(255, 255, 255, 0.92);
  --bottom-nav-bg: rgba(255, 255, 255, 0.82);
  --danger: #b42318;
  --danger-bg: #fef3f2;
  --danger-border: #fecdca;
  --danger-text: #b42318;
  --danger-ring: rgba(180, 35, 24, 0.28);
  --ok: #067647;
  --ok-bg: #ecfdf3;
  --ok-text: #067647;
  --like: #d92d20;
  --surface: var(--panel-2);
  --surface-muted: var(--panel-2);
  --surface-unread: var(--accent-soft);
  --skeleton-base: #eef1f6;
  --skeleton-shine: #f8fafc;
  --scrim: rgba(15, 17, 21, 0.42);
  --shadow: none;
  --shadow-sm: none;
  --shadow-md: none;
  --shadow-lg: none;
}

/* Dark — the night palette from loople.id. */
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1115;
  --bg-soft: #1f232c;
  --card-bg: #171a21;
  --card: var(--card-bg);
  --panel: var(--card-bg);
  --bg-elevated: var(--card-bg);
  --panel-2: #1f232c;
  --text: #f0f2f5;
  --ink: var(--text);
  --muted: #9aa2b1;
  --line: #2a2f3a;
  --border: var(--line);
  --chip: #1f232c;
  --accent: #7c9bff;
  --accent-strong: #a9bdff;
  --accent-soft: rgba(124, 155, 255, 0.16);
  --on-accent: #10131a;
  --accent-ink: var(--on-accent);
  --header-bg: rgba(15, 17, 21, 0.92);
  --bottom-nav-bg: rgba(15, 17, 21, 0.85);
  --danger: #ff8b82;
  --danger-bg: #2a1614;
  --danger-border: #5b2a26;
  --danger-text: #ffb4ae;
  --danger-ring: rgba(255, 139, 130, 0.3);
  --ok: #7ee2ae;
  --ok-bg: #12251b;
  --ok-text: #a7ecc7;
  --like: #ff8b82;
  --surface: var(--panel-2);
  --surface-muted: var(--panel-2);
  --surface-unread: var(--accent-soft);
  --skeleton-base: #1f232c;
  --skeleton-shine: #2a2f3a;
  --scrim: rgba(0, 0, 0, 0.6);
  --shadow: none;
  --shadow-sm: none;
  --shadow-md: none;
  --shadow-lg: none;
}

/* Greige — more grey than light, with a light warm beige tint. */
html[data-theme="greige"] {
  color-scheme: light;
  --bg: #e8e6e1;
  --bg-soft: #dedbd4;
  --card-bg: #f4f2ed;
  --card: var(--card-bg);
  --panel: var(--card-bg);
  --bg-elevated: var(--card-bg);
  --panel-2: #eae7e1;
  --text: #23221e;
  --ink: var(--text);
  --muted: #6a675f;
  --line: #d6d2c9;
  --border: var(--line);
  --chip: #e4e1da;
  --accent: #4a639c;
  --accent-strong: #3a4f80;
  --accent-soft: rgba(74, 99, 156, 0.13);
  --on-accent: #ffffff;
  --accent-ink: var(--on-accent);
  --header-bg: rgba(244, 242, 237, 0.92);
  --bottom-nav-bg: rgba(244, 242, 237, 0.85);
  --danger: #a63d34;
  --danger-bg: #f7e9e7;
  --danger-border: #e4c3bf;
  --danger-text: #8e3129;
  --danger-ring: rgba(166, 61, 52, 0.28);
  --ok: #4a6b4a;
  --ok-bg: #e9f0e6;
  --ok-text: #3d5c3d;
  --like: #b4473d;
  --surface: var(--panel-2);
  --surface-muted: var(--panel-2);
  --surface-unread: var(--accent-soft);
  --skeleton-base: #e4e1da;
  --skeleton-shine: #f0eee9;
  --scrim: rgba(35, 34, 30, 0.4);
  --shadow: none;
  --shadow-sm: none;
  --shadow-md: none;
  --shadow-lg: none;

  /* Warm note cards for the greige surface; swatches stay pastel. */
  --note-sage-card: #dfe6d6;
  --note-sage-border: #ccd7c0;
  --note-peach-card: #f0dccd;
  --note-peach-border: #e2c6b2;
  --note-sand-card: #ece2c8;
  --note-sand-border: #dccfae;
  --note-rose-card: #eedadd;
  --note-rose-border: #dfc3c9;
  --note-sky-card: #dbe4ea;
  --note-sky-border: #c4d2db;
  --note-lavender-card: #e2dceb;
  --note-lavender-border: #cec5dc;
  --note-mint-card: #d9e6df;
  --note-mint-border: #c1d6cc;
}

/* Geometry, type and controls: identical in every theme. */
:root {
  --radius: 14px;
  --radius-sm: 9px;
  --radius-lg: 14px;
  --radius-pill: 999px;
  --pad: 24px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --mono: var(--font-mono);
  --font: 16px/1.55 var(--font-sans);
  --text-xs: 12px;
  --text-sm: 13.5px;
  --text-md: 15px;
  --text-base: 16px;
  --text-lg: 18px;
  --text-xl: 22px;
  --header-height: var(--loople-header-height, 55px);
  --sidebar-width: 264px;
  --bottom-nav-height: 64px;
}

/* ------------------------------------------------------------------ */
/* Shared component rules                                              */
/* ------------------------------------------------------------------ */

html {
  background: var(--bg);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
}

:where(a) {
  color: inherit;
  text-decoration-color: color-mix(in srgb, var(--muted) 55%, transparent);
  text-underline-offset: 3px;
}

:where(a):hover {
  color: var(--accent);
  text-decoration-color: currentColor;
}

:where(.article, .post .body, .comment-body, .note-body) a {
  text-decoration: underline;
}

/* One card recipe: border, radius, padding, no mixed shadows. */
:where(.card, .panel, .post, .note-card, .settings-panel) {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card-bg);
  box-shadow: none;
}

:where(.card, .panel, .note-card, .settings-panel) {
  padding: var(--pad);
}

/* News cards own their inset in .card-body. */
article.card:has(> .card-body) {
  padding: 0;
  overflow: hidden;
}

/* One button recipe. */
:where(.btn, .button, .button-primary, .button-ghost, .button-danger,
    .action, button.button) {
  min-height: 42px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  box-shadow: none;
  font-weight: 600;
}

:where(.btn, .button, .button-primary, .button-ghost, .button-danger,
    .action, button.button):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

:where(.btn:not(.ghost):not(.danger), .button-primary,
    .action:not(.secondary):not(.done)) {
  border-color: transparent;
  background: var(--accent);
  color: var(--on-accent);
}

:where(.btn.ghost, .button:not(.button-primary), .button-ghost,
    .action.secondary) {
  border: 1px solid var(--line);
  background: var(--card-bg);
  color: var(--text);
}

:where(.btn, .button, .button-primary, .button-ghost, .button-danger,
    .action):hover {
  filter: brightness(0.96);
}

:where(.btn, .button, .button-primary, .button-ghost, .button-danger,
    .action):active {
  filter: brightness(0.9);
}

:where(.btn, .button, button):disabled {
  opacity: 0.5;
  filter: none;
}

/* Inputs share the control radius, sharper than cards. */
:where(
    input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="submit"]):not([type="button"]):not([type="file"]),
    textarea,
    select
  ) {
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background-color: var(--bg);
  color: var(--text);
  box-shadow: none;
  font-size: 16px;
}

:where(input, textarea, select):focus {
  border-color: var(--accent);
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* Navigation: compact pills, chip on the active item. */
:where(.primary-nav, .site-nav) a {
  padding: 6px 10px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}

:where(.primary-nav, .site-nav) a:hover {
  background: var(--chip);
  color: var(--text);
}

:where(.primary-nav, .site-nav) a.is-active {
  background: var(--chip);
  color: var(--accent);
  font-weight: 600;
}

/* One bottom navigation geometry for social, my and news. */
.bottom-nav,
.mobilebar {
  border-top: 1px solid var(--line);
  background: var(--bottom-nav-bg);
  box-shadow: none;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.bottom-nav,
.mobilebar {
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0px));
}

.bottom-nav-link,
.mobilebar a,
.mobilebar button {
  min-height: 48px;
  padding: 4px 2px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.15;
}

.bottom-nav-link svg,
.bottom-nav-add svg,
.mobilebar svg {
  width: 22px;
  height: 22px;
}

/* The compose action is a normal tab, not a raised button: one bar height
   in every service. */
.bottom-nav-add {
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  margin: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--accent);
  box-shadow: none;
}

.bottom-nav-link.is-active,
.bottom-nav-link[aria-current="page"],
.mobilebar a.active,
.mobilebar button.active {
  background: var(--chip);
  color: var(--accent);
}

/* Reader mode, shared by news, notes and the social feed. */
html.text-mode img,
html.text-mode picture,
html.text-mode video,
html.text-mode .card-image-link,
html.text-mode .article-figure,
html.text-mode .skeleton-image {
  display: none !important;
}

html.text-mode .card,
html.text-mode .article {
  background: var(--panel);
}

html.text-mode body {
  max-width: 72ch;
  margin-inline: auto;
}

loople-theme-picker {
  display: block;
}

/* Danger zone keeps the warning colour instead of a neutral border. */
.danger-zone {
  border-color: var(--danger-ring);
}

/* Desktop geometry from loople.id: headings and tiles. */
h1 {
  font-size: 28px;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

h2 {
  font-size: 18px;
  letter-spacing: -0.01em;
}

.lead {
  color: var(--muted);
  font-size: 17px;
}

.card-body {
  gap: 8px;
  padding: 16px 16px 17px;
}

.card-title {
  font-size: clamp(17px, 1.6vw, 21px);
  line-height: 1.24;
}

.card-source {
  font-size: 11.5px;
  letter-spacing: 0.05em;
}

.card-footer .card-meta {
  font-size: 12px;
}


/* ======================================================================
   Loople UI shell — one skeleton for every service.
   ======================================================================
   <loople-header> lives in the shadow DOM; everything below styles the
   light-DOM slots it exposes, so a service only supplies its local
   sections and never its own header, rail or brand.  Change here once and
   news, social, my, id and hub follow. */

body.loople-shell {
  padding-left: var(--loople-shell-width, 248px);
}

@media (max-width: 900px) {
  body.loople-shell {
    padding-left: 0;
  }
}

/* The sidebar sections supplied through <slot name="nav">. */
[slot="nav"] {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

[slot="nav"] a {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 9px;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 550;
  line-height: 1.25;
  text-decoration: none;
  transition: background 120ms ease, color 120ms ease;
}

[slot="nav"] a:hover {
  background: var(--chip);
  text-decoration: none;
}

[slot="nav"] a.is-active,
[slot="nav"] a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 650;
}

[slot="nav"] a svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  color: var(--muted);
}

[slot="nav"] a.is-active svg,
[slot="nav"] a[aria-current="page"] svg {
  color: var(--accent);
}

[slot="nav"] .nav-title,
[slot="nav"] .side-title {
  margin: 12px 10px 5px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Badges inside section links keep their own compact shape. */
[slot="nav"] .rail-badge,
[slot="nav"] .nav-badge,
[slot="nav"] .count {
  margin-left: auto;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 10.5px;
  font-weight: 700;
  line-height: 16px;
}

/* Extra tools under the sections (e.g. a service action button). */
[slot="side-tools"] {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* The drawer disables page scroll underneath it. */
body.loople-drawer-open {
  overflow: hidden;
}

/* Content areas never need their own top offset: the shell bar is sticky
   and in normal flow.  Services that used a fixed header must drop it. */
body.loople-shell .site-header,
body.loople-shell .app-header {
  display: none !important;
}
