/* ============================================================
   kungurov.net — ICI THEME PORT (light, Inter, narrow content)
   Based on Ici WordPress theme by Automattic
   ============================================================ */

:root {
  /* Ici palette */
  --base:       #1a1a1a;
  --contrast:   #e0e0e0;
  --primary:    #888888;
  --secondary:  #333333;
  --tertiary:   #cccccc;
  --accent:     #60a5fa;

  /* Type */
  --font-sans:  'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  --font-mono:  'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  --font-display: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;

  /* Ici spacing scale (mapped from --wp--preset--spacing--*) */
  --space-20:   2px;
  --space-30:   6px;
  --space-40:   10px;
  --space-50:   16px;
  --space-60:   24px;
  --space-70:   32px;
  --space-80:   48px;

  /* Content width — Ici uses 400px for a narrow reading column */
  --content-w:  800px;
  --wide-w:     92vw;

  /* Misc */
  --radius:     2px;
  --ease:       cubic-bezier(0.22, 0.7, 0.2, 1);
  --dur:        0.18s;
}

/* ---------- scrollbar ---------- */
* { scrollbar-width: thin; scrollbar-color: var(--secondary) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--secondary); border-radius: 999px; }
*::-webkit-scrollbar-thumb:hover { background: var(--primary); }
*::-webkit-scrollbar-corner { background: transparent; }

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--base);
  color: var(--contrast);
  font-family: var(--font-sans);
  font-size: 1rem;       /* Ici tiny */
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--tertiary);
  text-decoration: none;
  transition: color var(--dur) var(--ease);
}
a:hover { color: var(--primary); text-decoration: none; }

:focus-visible {
  outline: 2px solid var(--tertiary);
  outline-offset: 2px;
  border-radius: var(--radius);
}
:focus:not(:focus-visible) { outline: none; }

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

/* ---------- skip link ---------- */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-50);
  background: var(--tertiary);
  color: var(--base);
  padding: var(--space-30) var(--space-50);
  z-index: 100;
  font-size: 0.9rem;
}
.skip-link:focus { top: var(--space-30); }

/* ---------- layout ---------- */
.layout {
  max-width: var(--content-w);
  margin: 0 auto;
  padding: 0 var(--space-30);
}

.site-header {
  padding: var(--space-80) var(--space-30) var(--space-60);
  text-align: left;
}
.site-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1.1;
  color: var(--contrast);
  letter-spacing: -0.02em;
}
.site-title a { color: inherit; }
.site-title a:hover { color: var(--primary); }
.site-tagline {
  font-size: 0.85rem;
  color: var(--primary);
  margin-top: var(--space-30);
  line-height: 1.4;
}
.site-nav {
  margin-top: var(--space-30);
  display: flex;
  gap: var(--space-50);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.site-nav a {
  color: var(--primary);
}
.site-nav a:hover {
  color: var(--tertiary);
}
.site-header .sep {
  margin-top: var(--space-60);
  border: 0;
  border-top: 1px solid var(--secondary);
}

.post-list {
  padding: 0; /* .layout already insets the column */
}
.post-list .post-item {
  padding: var(--space-70) 0;
  display: flow-root;
  /* --poke lives on the shared parent so both the float grid and the
     text column can use it (custom properties don't inherit sideways) */
  --poke: calc(-1 * (207px + var(--space-50)));
}
.post-list .post-item + .post-item {
  border-top: none;
}
.post-thumb {
  float: left;
  width: 207px;
  aspect-ratio: 1;
  margin-right: 0;
  /* push the WHOLE grid left of the name's left edge (into the margin) */
  margin-left: var(--poke);
  border-radius: 12px 0 0 12px;
}
.post-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
/* Post thumb as a 4x4 tetris field: top-right = cover, a random tetromino
   fills cells with images; every piece fits in every rotation. */
.post-thumb.tetris-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 3px;
  aspect-ratio: auto;
  padding: 3px;
  background: transparent; /* no bg -> drop-shadow follows only the figure */
  /* colored 3px border hugging the figure silhouette (8 directions) */
  filter: drop-shadow(3px 0 0 var(--fig-color)) drop-shadow(-3px 0 0 var(--fig-color))
          drop-shadow(0 3px 0 var(--fig-color)) drop-shadow(0 -3px 0 var(--fig-color))
          drop-shadow(3px 3px 0 var(--fig-color)) drop-shadow(-3px 3px 0 var(--fig-color))
          drop-shadow(3px -3px 0 var(--fig-color)) drop-shadow(-3px -3px 0 var(--fig-color));
}
.post-thumb.tetris-grid .tetris-cell {
  width: 100%;
  aspect-ratio: 1;
  display: block;
  margin: 0;
  position: relative;
  z-index: 1;
}
.post-thumb.tetris-grid .tetris-cell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none; /* hover hits the cell box, not the enlarged image */
  transition: transform 325ms var(--ease);
}
.post-thumb.tetris-grid .tetris-cell:hover {
  z-index: 3;
}
.post-thumb.tetris-grid .tetris-cell:hover img {
  transform: scale(4); /* 2x the previous zoom (was scale 2) */
}
.post-thumb.tetris-grid .tetris-empty {
  visibility: hidden;
}
.post-thumb.tetris-grid .tetris-hidden {
  visibility: hidden;
}
.post-list .post-info {
  display: flex;
  align-items: flex-start;
  column-gap: var(--space-70);
  row-gap: var(--space-20);
  /* title starts right after the grid: follows the grid's right edge */
  margin-left: calc(var(--poke) + 207px + var(--space-50));
  background: none;
  padding: 0 0 4px;
}
.post-list .post-title {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.35;
  /* cancel first-line half-leading ((1.35-1)*1.4rem/2) so the text top
     aligns flush with the tetris-grid's first row (post-info pad 3px) */
  margin: -0.245rem 0 0;
  display: block;
  flex: 0 1 auto;
  min-width: 0;
  background: none;
  border-radius: 0;
  padding: 0;
}
.post-list .post-meta {
  display: inline-flex;
  align-items: baseline;
  gap: var(--space-40);
  white-space: nowrap;
  font-size: 0.85rem;
  line-height: 1.35;
  /* same half-leading compensation as the title ((1.35-1)*0.85rem/2) */
  margin-top: -0.14875rem;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: none;
  border-radius: 0;
  padding: 0;
  mask-image: none;
  -webkit-mask-image: none;
}
.post-list .post-tag {
  color: var(--tertiary);
}
.post-list .post-cat {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--tertiary);
  background: var(--secondary);
  padding: 2px 8px;
  border-radius: var(--radius);
}
.post-list .post-date {
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.post-list .post-cat {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--tertiary);
  background: var(--secondary);
  padding: 2px 8px;
  border-radius: var(--radius);
}

/* ---------- pagination ---------- */
.pagination {
  padding: var(--space-50) var(--space-30);
  border-top: 1px solid var(--secondary);
  display: flex;
  justify-content: space-between;
  gap: var(--space-30);
  font-size: 0.85rem;
}
.pagination a { color: var(--contrast); }
.pagination a:hover { color: var(--primary); }
.pagination .is-disabled { opacity: 0.35; cursor: not-allowed; }

/* ---------- Ici single post ---------- */
.post {
  padding: var(--space-30) var(--space-30) var(--space-50);
}
.post__back {
  margin-bottom: var(--space-50);
  font-size: 0.85rem;
}
.post__back a { color: var(--primary); }
.post__back a:hover { color: var(--tertiary); }

.post__header {
  margin-bottom: var(--space-50);
}
.post__topline {
  margin-bottom: var(--space-30);
}
.breadcrumbs {
  font-size: 0.85rem;
  color: var(--primary);
  margin-bottom: var(--space-30);
}
.breadcrumbs a { color: var(--primary); }
.breadcrumbs a:hover { color: var(--tertiary); }
.breadcrumbs__list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.breadcrumbs__sep { color: var(--secondary); }

.post__meta {
  font-size: 0.85rem;
  color: var(--primary);
  display: flex;
  gap: 6px;
  align-items: center;
}
.post__meta-sep { color: var(--secondary); }

.post__title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1.1;
  color: var(--contrast);
  margin: 0;
}

.post__cover-wrap {
  margin: var(--space-50) 0;
}
.post__cover {
  width: 100%;
  border-radius: var(--radius);
}

/* ---------- prose (post body) ---------- */
.prose {
  font-size: 1.1rem;
  line-height: 1.6;
  color: var(--contrast);
}
.prose h1 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.1;
  margin: var(--space-70) 0 var(--space-30);
  font-size: 1.75rem;
}
.prose h2 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.1;
  margin: calc(var(--space-70) + 40px) 0 var(--space-30);
  font-size: 1.4rem;
}
.prose h3 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.1;
  margin: calc(var(--space-70) + 40px) 0 var(--space-30);
  font-size: 1.2rem;
}
.prose h4 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  text-transform: uppercase;
  font-weight: 600;
  margin: calc(var(--space-60) + 40px) 0 var(--space-30);
}
.prose h5 {
  font-family: var(--font-display);
  font-size: 1rem;
  text-transform: uppercase;
  font-weight: 400;
  margin: calc(var(--space-60) + 40px) 0 var(--space-30);
}
.prose h6 {
  font-family: var(--font-display);
  font-size: 0.85rem;
  text-transform: uppercase;
  font-weight: 400;
  margin: calc(var(--space-60) + 40px) 0 var(--space-30);
}
.prose p {
  margin-bottom: var(--space-50);
}
.prose a {
  text-decoration: underline;
  color: var(--accent);
}
.prose a:hover { color: var(--primary); text-decoration: none; }
.prose ul, .prose ol {
  margin: 0 0 var(--space-50) var(--space-70);
}
.prose li {
  margin-bottom: var(--space-20);
}
.prose blockquote {
  border-left: 2px solid var(--secondary);
  margin: 0 0 var(--space-50);
  padding-left: var(--space-50);
  font-style: normal;
}
.prose blockquote cite {
  font-size: 0.9rem;
  font-style: normal;
  color: var(--primary);
}
.prose pre {
  background: #222222;  /* dark-theme default; overridden for light below */
  border-left: 3px solid var(--secondary);
  border-radius: 0;
  padding: var(--space-50) var(--space-60);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.7;
  margin-bottom: var(--space-50);
}
.prose code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: #2a2a2a;  /* dark-theme default; overridden for light below */
  padding: 1px 5px;
  border-radius: 3px;
}
.prose pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  font-size: 0.85rem;
}

.copy-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  background: var(--base);
  border: 1px solid var(--secondary);
  border-radius: 4px;
  padding: 3px 10px;
  font-size: 0.7rem;
  color: var(--primary);
  cursor: pointer;
  font-family: var(--font-sans);
  transition: all 0.12s ease;
  line-height: 1.4;
}
.copy-btn:hover {
  background: var(--secondary);
  color: var(--contrast);
}
.prose pre code { font-size: 0.9rem; }
.prose img {
  margin: var(--space-50) 0;
  border-radius: var(--radius);
}
.prose table {
  display: block; /* wide tables scroll horizontally instead of squeezing */
  width: max-content;
  max-width: 100%;
  overflow-x: auto;
  white-space: nowrap;
  border-collapse: collapse;
  margin-bottom: var(--space-50);
  font-size: 0.9rem;
}
.prose th, .prose td {
  padding: var(--space-30);
  border: 1px solid var(--secondary);
  text-align: left;
}
.prose th { font-weight: 600; }
.prose figcaption {
  font-size: 0.7rem;
  color: var(--primary);
  text-align: center;
  margin-top: var(--space-20);
}
.prose hr {
  border: 0;
  border-top: 1px solid var(--secondary);
  margin: var(--space-50) 0;
}
.prose .wp-block-separator { margin: 0; }

/* ---------- post footer (tags, author, nav) ---------- */
.post__footer {
  margin-top: var(--space-60);
  padding-top: var(--space-50);
  border-top: 1px solid var(--secondary);
}
.post__tags {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: var(--space-50);
}
.post__tags a { color: var(--primary); }
.post__tags a:hover { color: var(--tertiary); }
.post__author {
  font-size: 1rem;
  color: var(--primary);
  margin-bottom: var(--space-30);
}
.post__author a { color: var(--primary); }
.post__author a:hover { color: var(--tertiary); }
.post__date {
  font-size: 1rem;
  color: var(--primary);
}
.post__nav {
  display: flex;
  justify-content: space-between;
  gap: var(--space-50);
  margin-top: var(--space-50);
  font-size: 0.85rem;
}
.post__nav a { color: var(--contrast); }
.post__nav a:hover { color: var(--primary); }

/* ---------- Ici footer ---------- */
.site-footer {
  padding: var(--space-60) var(--space-30);
  text-align: center;
  font-size: 0.9rem;
  color: var(--primary);
}
.site-footer a { color: var(--primary); }
.site-footer a:hover { color: var(--tertiary); }

/* ---------- about nav ---------- */
.about__nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-30);
  margin-bottom: var(--space-50);
  font-size: 0.85rem;
}
.about__nav a { color: var(--primary); }
.about__nav a:hover { color: var(--tertiary); }

.about__visual ul {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-30);
  padding: 0;
  margin: var(--space-50) 0;
}
.about__visual li {
  overflow: hidden;
  border-radius: var(--radius);
  aspect-ratio: 1;
}
.about__visual li:nth-child(3n) {
  grid-column: span 2;
  grid-row: span 2;
}
.about__visual li:nth-child(5n) {
  grid-column: span 2;
}
.about__visual img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity 0.12s ease;
}
.about__visual a:hover img {
  opacity: 0.8;
}

/* ---------- page head (se.html) ---------- */
.page-head {
  padding: var(--space-30) var(--space-30) var(--space-50);
}
.page-head__title {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.1;
}
.page-head__sub {
  font-size: 0.9rem;
  color: var(--primary);
  margin-top: var(--space-20);
}

/* ---------- works grid (se.html) ---------- */
.works-grid {
  list-style: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-50);
  padding: 0 var(--space-30) var(--space-60);
}
@media (max-width: 500px) {
  .works-grid { grid-template-columns: 1fr; }
}
.work-card__link {
  display: block;
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
}
.work-card__img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  display: block;
}
.work-card__overlay {
  position: absolute;
  inset: 0;
  background: rgba(251,251,251,0.9);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  opacity: 0;
  transition: opacity var(--dur) var(--ease);
  padding: var(--space-30);
  text-align: center;
}
.work-card__link:hover .work-card__overlay { opacity: 1; }
.work-card__title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--contrast);
  margin-bottom: var(--space-20);
}
.work-card__meta {
  font-size: 0.7rem;
  color: var(--primary);
  display: flex;
  gap: var(--space-30);
}

/* ---------- lightbox ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0,0,0,0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-50);
}
.lightbox[hidden] { display: none; }
.lightbox__close {
  position: absolute;
  top: var(--space-30);
  right: var(--space-30);
  background: none;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  z-index: 1;
}
.lightbox__img {
  max-width: 90vw;
  max-height: 80vh;
  object-fit: contain;
}
.lightbox__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
  padding: var(--space-30);
}
.lightbox__nav--prev { left: var(--space-30); }
.lightbox__nav--next { right: var(--space-30); }
.lightbox__caption {
  color: #ccc;
  font-size: 0.9rem;
  margin-top: var(--space-30);
  text-align: center;
}

@media (max-width: 1240px) {
  /* not enough left margin: pull the grid back to a small overhang */
  .post-list .post-item { --poke: -48px; }
  /* grid sits flush with the title here, but its 3px colored drop-shadow
     overlaps the first letter — leave a clearance for the shadow */
  .post-list .post-info { margin-left: calc(var(--poke) + 207px + var(--space-50) + 4px); }
}

/* ---------- tablet ---------- */
@media (max-width: 900px) {
  /* container is full-width here, so a big poke would push the grid
     off-screen; keep just enough to tuck it into the side padding */
  .post-list .post-item { --poke: -12px; }
  .post-list .post-title { font-size: 1.3rem; }
}

/* ---------- phones: cover square left of the title ---------- */
@media (max-width: 700px) {
  .post-list .post-item { display: flow-root; --poke: 0; padding: 20px 0; }
  /* the 4x4 grid collapses to just the cover cell (top-right square),
     floated left of the title; no colored contour on a lone square */
  .post-thumb {
    float: left;
    width: 64px;
    height: 64px;
    margin: 0 16px 8px 0;
    border-radius: 8px;
  }
  .post-thumb.tetris-grid {
    display: block;
    padding: 0;
    gap: 0;
  }
  .post-thumb.tetris-grid .tetris-cell {
    display: none;
    pointer-events: none; /* no hover-zoom on touch */
  }
  .post-thumb.tetris-grid .tetris-cover { display: block; }
  /* posts without a cover: no square at all, title stays full-width */
  .post-thumb:not(:has(.tetris-cover)) { display: none; }
  .post-list .post-info {
    margin-left: 0;
    padding: 0; /* drop the 4px bottom pad: it inflates title-to-title gap */
    flex-direction: column;
    align-items: stretch; /* not flex-start: the title must shrink to wrap */
  }
  .post-item:has(.tetris-cover) .post-info { margin-left: 80px; } /* 64 + 16 */
  .post-list .post-title {
    font-size: 1.25rem;
    margin-top: 0; /* no grid to align with: drop the half-leading nudge */
    overflow-wrap: break-word; /* long titles must wrap on tiny screens */
  }
  .post-list .post-meta {
    margin-top: 0;
    white-space: normal;
    flex-wrap: wrap;
    font-size: 0.7rem; /* shrink the date so title-to-title gap hits 3x */
    line-height: 1.2;
  }
  .site-nav { flex-wrap: wrap; }
  .prose {
    font-size: 1rem;
    overflow-wrap: break-word;
  }
  .prose pre { font-size: 0.8rem; }
  .prose h2, .prose h3, .prose h4, .prose h5, .prose h6 {
    margin: calc(var(--space-60) + 20px) 0 var(--space-30);
  }
  .post__title { font-size: 1.35rem; }
  .pagination { flex-wrap: wrap; }
}

/* ---------- responsive ---------- */
@media (max-width: 480px) {
  :root { --content-w: 100%; }
  .site-header { padding-top: var(--space-60); }
  .post-list .post-item { padding: 8px 0; }
  .works-grid { gap: var(--space-30); }
}

/* ---------- light theme ---------- */
@media (prefers-color-scheme: light) {
  :root {
    --base:       #fbfbfb;
    --contrast:   #3f3f3f;
    --primary:    #8a8a8a;
    --secondary:  #dcdcdc;
    --tertiary:   #2f2f2f;
    --accent:     #2563eb;
  }
  .prose pre { background: #f5f5f3; }
  .prose code { background: #f0f0ee; }
  .work-card__overlay { background: rgba(251,251,251,0.9); }
  .lightbox { background: rgba(0,0,0,0.85); }
  .post-list .post-cat { background: var(--secondary); }
  .post-list .post-date { color: var(--primary); }
}
