/*
Theme Name: Wikirobot
Theme URI: https://wikirobot.test
Author: Wikirobot
Description: Справочник по роботам, чипам и технике — тема для wikirobot.test.
Version: 1.0.0
Requires PHP: 8.0
Text Domain: wikirobot
*/

:root {
  color-scheme: light;
  --bg: #F3F1EC;
  --surface: #FFFFFF;
  --surface-2: #EDEAE2;
  --fg: #1C1B18;
  --muted: #6E6A5F;
  --border: #E1DDD1;
  --accent: #C06B1E;
  --accent-fill: #E2933F;
  --on-accent: #1B1509;
  --ring: #C06B1E;
  --font-sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  --radius-card: 14px;
  --radius-pill: 999px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #15171B;
    --surface: #1E2126;
    --surface-2: #262A31;
    --fg: #ECE8E1;
    --muted: #9B968B;
    --border: #2B2F37;
    --accent: #E2933F;
    --accent-fill: #E2933F;
    --on-accent: #1B1509;
    --ring: #E2933F;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #15171B;
  --surface: #1E2126;
  --surface-2: #262A31;
  --fg: #ECE8E1;
  --muted: #9B968B;
  --border: #2B2F37;
  --accent: #E2933F;
  --accent-fill: #E2933F;
  --on-accent: #1B1509;
  --ring: #E2933F;
}

* { box-sizing: border-box; }

html { text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

img { max-width: 100%; height: auto; }

.wrap {
  max-width: 1180px;
  margin-inline: auto;
  padding-inline: clamp(16px, 4vw, 48px);
}

a { color: inherit; }

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

h1, h2, h3 { font-family: var(--font-sans); text-wrap: balance; margin: 0; }

.icon { width: 1em; height: 1em; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

/* ---------- NAV ---------- */
.nav { border-bottom: 1px solid var(--border); background: var(--bg); }
.nav .wrap { height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.05rem; letter-spacing: -0.01em; text-decoration: none; white-space: nowrap; }
.brand { min-width: 0; }
.brand-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 1000px) { .brand-rest { display: none; } }
.brand .mark { flex-shrink: 0; width: 30px; height: 30px; border-radius: 8px; background: var(--accent-fill); color: var(--on-accent); display: flex; align-items: center; justify-content: center; }
.brand .mark .icon { width: 18px; height: 18px; stroke-width: 2; }
.nav-links { display: flex; gap: 28px; font-size: 0.92rem; color: var(--muted); list-style: none; margin: 0; padding: 0; }
.nav-links a { text-decoration: none; transition: color 150ms ease; }
.nav-links a:hover { color: var(--fg); }
.nav-right { display: flex; align-items: center; gap: 14px; }
.theme-toggle { width: 36px; height: 36px; border-radius: var(--radius-pill); border: 1px solid var(--border); background: var(--surface); color: var(--fg); display: flex; align-items: center; justify-content: center; cursor: pointer; transition: border-color 150ms ease, transform 120ms ease; }
.theme-toggle:hover { border-color: var(--accent); }
.theme-toggle:active { transform: scale(0.94); }
.theme-toggle .icon { width: 17px; height: 17px; }
.theme-toggle .moon { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .sun { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .moon { display: block; }
}
@media (max-width: 720px) { .nav-links { display: none; } }

/* ---------- HERO ---------- */
.hero { padding-block: clamp(40px, 7vw, 76px) clamp(32px, 6vw, 56px); }
.hero h1 { font-size: clamp(2.1rem, 4.2vw, 3.2rem); line-height: 1.08; letter-spacing: -0.02em; font-weight: 700; }
.hero p.lede { margin: 20px 0 0; max-width: 68ch; color: var(--muted); font-size: 1.08rem; line-height: 1.55; }
.hero .search-form { max-width: 680px; }
.search-form { margin-top: 32px; display: flex; gap: 10px; max-width: 480px; }
.search-field { flex: 1; display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-pill); padding: 0 18px; height: 52px; transition: border-color 150ms ease; }
.search-field:focus-within { border-color: var(--accent); }
.search-field .icon { color: var(--muted); width: 18px; height: 18px; }
.search-field input { border: none; outline: none; background: none; font-family: var(--font-sans); font-size: 0.98rem; color: var(--fg); width: 100%; }
.search-field input::placeholder { color: var(--muted); }
.search-submit { height: 52px; padding: 0 24px; border-radius: var(--radius-pill); border: none; background: var(--accent-fill); color: var(--on-accent); font-family: var(--font-sans); font-weight: 600; font-size: 0.95rem; cursor: pointer; transition: filter 150ms ease, transform 120ms ease; white-space: nowrap; }
.search-submit:hover { filter: brightness(1.08); }
.search-submit:active { transform: translateY(1px); }

/* ---------- INFOBOX (single article) ---------- */
.infobox { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); overflow: hidden; }
.infobox-body { padding: 18px 20px 20px; }
.infobox-title { font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin-bottom: 12px; }
.infobox-rows { margin: 0; }
.infobox-row { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 0.86rem; }
.infobox-row:last-child { border-bottom: none; }
.infobox-row dt { color: var(--muted); font-weight: 500; }
.infobox-row dd { margin: 0; font-family: var(--font-mono); font-size: 0.82rem; color: var(--fg); text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- SECTION HEADS ---------- */
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.section-head h2 { font-size: clamp(1.35rem, 2.2vw, 1.7rem); font-weight: 700; letter-spacing: -0.01em; }
.section-head a.all-link { font-size: 0.88rem; color: var(--muted); text-decoration: none; white-space: nowrap; transition: color 150ms ease; }
.section-head a.all-link:hover { color: var(--accent); }

/* ---------- ARTICLE GRID ---------- */
.featured { padding-block: 8px 48px; }
.featured-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 22px; }
.featured-grid.no-lead { grid-template-columns: repeat(3, 1fr); }
.article-card { display: block; text-decoration: none; color: var(--fg); border-radius: var(--radius-card); overflow: hidden; background: var(--surface); border: 1px solid var(--border); transition: border-color 150ms ease, transform 150ms ease; }
.article-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.article-card.lead { position: relative; grid-row: span 2; min-height: 420px; }
.article-card.lead img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: grayscale(0.35) sepia(0.12) contrast(1.05) brightness(0.85); }
.article-card.lead .scrim { position: absolute; inset: 0; background: linear-gradient(0deg, rgba(10,10,9,0.86) 0%, rgba(10,10,9,0.35) 45%, transparent 70%); }
.article-card.lead .card-copy { position: absolute; left: 0; right: 0; bottom: 0; padding: 26px; color: #F4F1EA; }
.article-card.lead .card-copy .cat { color: #E2933F; }
.article-card.lead .card-copy .title { color: #F4F1EA; font-size: 1.35rem; }
.article-card.lead .card-copy .excerpt { color: #CFCABE; }
.article-grid-small { display: grid; gap: 22px; }
.article-card.small { display: flex; flex-direction: column; }
.article-card.small .thumb { aspect-ratio: 16/9; overflow: hidden; background: var(--surface-2); }
.article-card.small .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; filter: grayscale(0.35) sepia(0.12) contrast(1.05) brightness(0.94); }
.card-copy { padding: 18px 20px 20px; }
.card-copy .cat { font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: 0.07em; text-transform: uppercase; color: var(--accent); }
.card-copy .title { margin-top: 8px; font-size: 1.02rem; font-weight: 600; line-height: 1.35; letter-spacing: -0.005em; }
.card-copy .excerpt { margin-top: 8px; font-size: 0.87rem; color: var(--muted); line-height: 1.5; }
.card-copy .meta { margin-top: 14px; font-family: var(--font-mono); font-size: 0.72rem; color: var(--muted); display: flex; gap: 10px; }
@media (max-width: 860px) {
  .featured-grid, .featured-grid.no-lead { grid-template-columns: 1fr; }
  .article-card.lead { grid-row: auto; min-height: 320px; }
}

.empty-state { padding: 40px; text-align: center; border: 1px dashed var(--border); border-radius: var(--radius-card); color: var(--muted); }

/* ---------- DIRECTORY (BENTO) ---------- */
.directory { padding-block: 56px 72px; }
.bento { display: grid; grid-template-columns: repeat(4, 1fr); grid-auto-rows: 128px; gap: 14px; }
.bento-cell { grid-column: span 1; grid-row: span 1; border-radius: var(--radius-card); border: 1px solid var(--border); background: var(--surface); padding: 18px; display: flex; flex-direction: column; justify-content: space-between; text-decoration: none; color: var(--fg); transition: border-color 150ms ease, background 150ms ease; position: relative; overflow: hidden; }
.bento-cell:hover { border-color: var(--accent); }
.bento-cell.big { grid-column: span 2; grid-row: span 2; }
.bento-cell.wide { grid-column: span 2; }
.bento-cell .icon-wrap { width: 38px; height: 38px; border-radius: 10px; background: var(--surface-2); display: flex; align-items: center; justify-content: center; color: var(--accent); }
.bento-cell.big .icon-wrap { width: 46px; height: 46px; }
.bento-cell.big .icon-wrap .icon { width: 24px; height: 24px; }
.bento-cell .cell-name { font-weight: 600; font-size: 0.95rem; }
.bento-cell.big .cell-name { font-size: 1.2rem; }
.bento-cell .cell-count { font-family: var(--font-mono); font-size: 0.72rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.bento-cell.accentfill { background: var(--accent-fill); color: var(--on-accent); border-color: transparent; }
.bento-cell.accentfill .icon-wrap { background: rgba(27,21,9,0.12); color: var(--on-accent); }
.bento-cell.accentfill .cell-count { color: rgba(27,21,9,0.65); }
.bento-cell.tint { background: var(--surface-2); }
@media (max-width: 860px) {
  .bento { grid-template-columns: repeat(2, 1fr); grid-auto-rows: 118px; }
  .bento-cell.big { grid-column: span 2; grid-row: span 1; flex-direction: row; align-items: center; gap: 14px; }
  .bento-cell.big .icon-wrap { margin-bottom: 0; }
  .bento-cell.wide { grid-column: span 2; }
}
@media (max-width: 480px) {
  .bento { grid-template-columns: 1fr; }
  .bento-cell.wide, .bento-cell.big { grid-column: span 1; }
}

/* ---------- SINGLE ARTICLE ---------- */
.article { padding-block: 40px 64px; }
.article-header { max-width: 68ch; margin-inline: auto; }
.article-header .cat { font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.07em; text-transform: uppercase; color: var(--accent); text-decoration: none; }
.article-header h1 { margin-top: 12px; font-size: clamp(1.8rem, 3.4vw, 2.6rem); line-height: 1.15; letter-spacing: -0.015em; }
.article-header .meta { margin-top: 14px; font-family: var(--font-mono); font-size: 0.78rem; color: var(--muted); display: flex; gap: 14px; flex-wrap: wrap; }
.article-media { max-width: 900px; margin: 32px auto 0; border-radius: var(--radius-card); overflow: hidden; border: 1px solid var(--border); }
.article-media img { display: block; width: 100%; }
.article-layout { max-width: 68ch; margin: 36px auto 0; display: grid; gap: 32px; }
.article-body { font-size: 1.05rem; line-height: 1.7; }
.article-body h2 { margin-top: 2em; font-size: 1.4rem; }
.article-body h3 { margin-top: 1.6em; font-size: 1.15rem; }
.article-body p { margin: 1em 0; }
.article-body a { color: var(--accent); }
.article-body img { border-radius: var(--radius-card); }
.article-body ul, .article-body ol { padding-left: 1.3em; }
.related { border-top: 1px solid var(--border); padding-block: 48px; }

/* ---------- FOOTER ---------- */
footer { border-top: 1px solid var(--border); padding-block: 32px; }
footer .wrap { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: space-between; color: var(--muted); font-size: 0.84rem; }
footer .foot-links { display: flex; gap: 20px; list-style: none; padding: 0; margin: 0; }
footer .foot-links a { color: var(--muted); text-decoration: none; transition: color 150ms ease; }
footer .foot-links a:hover { color: var(--fg); }

/* ---------- COOKIE NOTICE ---------- */
.cookie-notice { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -4px 20px rgba(0,0,0,0.08); }
.cookie-notice .wrap { padding-block: 16px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; }
.cookie-notice p { margin: 0; font-size: 0.86rem; color: var(--muted); }
.cookie-notice a { color: var(--accent); }
.cookie-notice button { flex-shrink: 0; height: 40px; padding: 0 20px; border-radius: var(--radius-pill); border: none; background: var(--accent-fill); color: var(--on-accent); font-family: var(--font-sans); font-weight: 600; font-size: 0.9rem; cursor: pointer; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
