/* Gridenberg – Frontend Styles v2.0.0 */

/* ─────────────────────────────────────────────────
   DESIGN TOKENS
───────────────────────────────────────────────── */
:root {
  --col: 12;
  --gap: 3px;
  --bg: #0a0a0a;
  --fg: #f0ede6;
  --fg-muted: #888;
  --accent: #e8d5b0;
  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-body: 'DM Sans', system-ui, sans-serif;
  --font-mono: 'DM Mono', monospace;
  --transition: 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  --header-h: 64px;
}

/* ─────────────────────────────────────────────────
   RESET & BASE
───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  /* background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body); */
  font-size: 0.9rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
a:hover { opacity: 0.7; }

/* Standard visually-hidden utility: keeps content in the
   accessibility tree / heading navigation without affecting layout. */
.gridenberg-sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ─────────────────────────────────────────────────
   TYPOGRAPHY
───────────────────────────────────────────────── */
h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 300;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

/* ─────────────────────────────────────────────────
   SITE HEADER
───────────────────────────────────────────────── */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  background: rgba(10,10,10,0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.site-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 300;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}

.site-nav {
  display: flex;
  gap: 32px;
  list-style: none;
}

.site-nav a {
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--fg-muted);
  transition: color var(--transition);
}

.site-nav a:hover { color: var(--fg); opacity: 1; }

/* ─────────────────────────────────────────────────
   MAIN CONTENT
───────────────────────────────────────────────── */
.site-main {
  padding-top: var(--header-h);
  min-height: 100vh;
}

/* ─────────────────────────────────────────────────
   PORTFOLIO GRID
───────────────────────────────────────────────── */
.portfolio-grid {
  display: grid;
  grid-template-columns: repeat(var(--col), 1fr);
  grid-auto-rows: calc((100vw - var(--ml, 0px) - var(--mr, 0px) - (var(--col) - 1) * var(--gap)) / var(--col));
  gap: var(--gap);
}

/* ─────────────────────────────────────────────────
   PORTFOLIO ITEM
───────────────────────────────────────────────── */
.portfolio-item {
  position: relative;
  overflow: hidden;
  cursor: pointer;
  background: #111;
}

/* Default placement fallback: 3 cols × 2 rows */
.portfolio-item {
  grid-column: span 3;
  grid-row: span 2;
}

.portfolio-item__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  filter: brightness(0.92);
  transition: filter 0.4s ease;
}

/* Reset margin thème sur figure */
figure.portfolio-item {
  margin: 0;
}

.portfolio-item:hover .portfolio-item__image {
  filter: brightness(1);
}

.portfolio-item__overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    rgba(0,0,0,0.75) 0%,
    rgba(0,0,0,0.2) 40%,
    transparent 70%
  );
  opacity: 0;
  transition: opacity var(--transition);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 24px;
}

.portfolio-item:hover .portfolio-item__overlay { opacity: 1; }

.portfolio-item__title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 300;
  color: #fff;
  letter-spacing: -0.01em;
  transform: translateY(8px);
  transition: transform var(--transition);
}

.portfolio-item:hover .portfolio-item__title { transform: translateY(0); }

.portfolio-item__meta {
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-top: 6px;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity var(--transition), transform var(--transition);
  transition-delay: 0.05s;
}

.portfolio-item:hover .portfolio-item__meta {
  opacity: 1;
  transform: translateY(0);
}

/* ─────────────────────────────────────────────────
   TEXT TILE
   The grid's rows are fixed square tracks (grid-auto-rows above) and
   every tile spans an explicit row range, so a text tile can NOT grow
   to fit its content without stretching the whole row for every other
   tile — long text scrolls inside the tile instead (same behavior as
   the admin editor preview). Font family is deliberately NOT set here
   (the tile inherits the theme's face); font-SIZE however scales with
   the tile itself via container query units, so the same text looks
   intentionally sized on a 1-col tile and on a 6-col tile alike.
   Genuine overflow keeps overflow-y:auto but hides the raw scrollbar
   and shows a bottom fade instead (.is-overflowing, toggled by main.js
   and removed once scrolled to the end so the last line is readable).
───────────────────────────────────────────────── */
.portfolio-item--text {
  cursor: default;               /* base .portfolio-item is pointer (image hover) */
  display: flex;
  flex-direction: column;
  justify-content: flex-start;   /* vertical align: top (default) */
  /* Size container: cqi units below resolve against the tile's own box.
     Safe here — the tile's size comes from the grid tracks, never from
     its content, so size containment changes nothing about layout. */
  container-type: size;
}

/* Vertical alignment (set from the editor; attribute omitted for the
   default so layouts saved before this feature render identically) */
.portfolio-item--text[data-valign="center"] { justify-content: center; }
.portfolio-item--text[data-valign="bottom"] { justify-content: flex-end; }

/* Horizontal alignment */
.portfolio-item--text[data-halign="center"] .portfolio-item__text-content { text-align: center; }
.portfolio-item--text[data-halign="right"]  .portfolio-item__text-content { text-align: right; }

.portfolio-item__text-content {
  /* %-padding scales with tile width; clamp keeps it sane on tiny/huge tiles */
  padding: clamp(14px, 7%, 40px);
  max-height: 100%;
  overflow-y: auto;
  overflow-wrap: break-word;
  line-height: 1.6;
  /* Fluid type: 1cqi = 1% of the tile's width (container-type on the tile).
     Old browsers drop the cqi declaration and keep the theme's size. */
  font-size: clamp(0.8rem, 2.2cqi + 0.55rem, 1.125rem);
  /* The fade below is the overflow cue — the raw scrollbar just adds noise
     (content stays wheel/touch/keyboard scrollable). */
  scrollbar-width: none;
}

.portfolio-item__text-content::-webkit-scrollbar { display: none; }

/* Genuine overflow → bottom fade-out instead of a hard clip. Toggled by
   main.js (scrollHeight vs clientHeight, minus current scroll position),
   so text that fits is never faded and the fade lifts at scroll end. */
.portfolio-item__text-content.is-overflowing {
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 36px), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 36px), transparent);
}

/* Heading scale in em so headings follow the container-scaled base size
   deterministically, whatever absolute sizes the active theme ships. */
.portfolio-item__text-content h1 { font-size: 2em; }
.portfolio-item__text-content h2 { font-size: 1.5em; }
.portfolio-item__text-content h3 { font-size: 1.25em; }

/* Vertical rhythm — deterministic regardless of the global reset above
   or whatever margins the active theme ships for these elements. */
.portfolio-item__text-content p,
.portfolio-item__text-content ul,
.portfolio-item__text-content ol,
.portfolio-item__text-content blockquote {
  margin: 0 0 0.75em;
}

.portfolio-item__text-content h1,
.portfolio-item__text-content h2,
.portfolio-item__text-content h3 {
  margin: 1.25em 0 0.5em;
}

.portfolio-item__text-content > :first-child { margin-top: 0; }
.portfolio-item__text-content > :last-child  { margin-bottom: 0; }

/* The global reset strips list padding — restore it or bullets/numbers
   render outside the tile (clipped by overflow:hidden). */
.portfolio-item__text-content ul,
.portfolio-item__text-content ol {
  padding-left: 1.3em;
  list-style-position: outside;
}

.portfolio-item__text-content li { margin-bottom: 0.3em; }
.portfolio-item__text-content li:last-child { margin-bottom: 0; }

/* Global `a` rule removes underlines — restore an affordance for links
   sitting inside prose. */
.portfolio-item__text-content a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ─────────────────────────────────────────────────
   CURATED TYPOGRAPHY CLASSES (rich text editor)
   Fixed, named classes only — never arbitrary inline styles (`class` is on
   wp_kses_post()'s default allow-list; `style` is not). Mirrored identically
   in admin/css/editor.css under .gb-e-grid-item__text-content so the editor
   preview always matches the published frontend. All sizes are em-based
   (relative to the tile's own fluid clamp() base size above) — never px.
───────────────────────────────────────────────── */

/* Font family — reuses the existing root custom properties; only these 3. */
.portfolio-item__text-content .gb-font-sans  { font-family: var(--font-body); }
.portfolio-item__text-content .gb-font-serif { font-family: var(--font-display); }
.portfolio-item__text-content .gb-font-mono  { font-family: var(--font-mono); }

/* Font size — 6 steps. */
.portfolio-item__text-content .gb-fs-xs  { font-size: 0.75em; }
.portfolio-item__text-content .gb-fs-sm  { font-size: 0.875em; }
.portfolio-item__text-content .gb-fs-md  { font-size: 1em; }
.portfolio-item__text-content .gb-fs-lg  { font-size: 1.25em; }
.portfolio-item__text-content .gb-fs-xl  { font-size: 1.5em; }
.portfolio-item__text-content .gb-fs-xxl { font-size: 2em; }

/* Line-height — 4 presets. */
.portfolio-item__text-content .gb-lh-tight   { line-height: 1.2; }
.portfolio-item__text-content .gb-lh-normal  { line-height: 1.6; }
.portfolio-item__text-content .gb-lh-relaxed { line-height: 1.9; }
.portfolio-item__text-content .gb-lh-loose   { line-height: 2.4; }

/* Paragraph alignment — a *separate* mechanism from the tile-wide [data-halign]
   rule above (which sets text-align on the .portfolio-item__text-content box
   itself). These rules target the specific block carrying the class, so they
   naturally win over the inherited tile-wide value with no specificity fight —
   a direct match on the element always beats an inherited computed value,
   regardless of source order. Kept after the tile-wide rules anyway for
   readability. */
.portfolio-item__text-content .gb-align-left    { text-align: left; }
.portfolio-item__text-content .gb-align-center  { text-align: center; }
.portfolio-item__text-content .gb-align-right   { text-align: right; }
.portfolio-item__text-content .gb-align-justify { text-align: justify; }

/* Letter-spacing / tracking — 3, including an explicit reset. */
.portfolio-item__text-content .gb-tracking-normal { letter-spacing: 0; }
.portfolio-item__text-content .gb-tracking-wide   { letter-spacing: 0.05em; }
.portfolio-item__text-content .gb-tracking-wider  { letter-spacing: 0.12em; }

/* Text transform / caps — 3, including an explicit reset. */
.portfolio-item__text-content .gb-caps-none  { text-transform: none; font-variant: normal; }
.portfolio-item__text-content .gb-caps-upper { text-transform: uppercase; }
.portfolio-item__text-content .gb-caps-small { font-variant: small-caps; }

/* Block quote — portfolio "pull quote" styling, not the unstyled browser
   default. Margin/vertical-rhythm handled by the shared rule above. */
.portfolio-item__text-content blockquote {
  padding-left: 1em;
  border-left: 2px solid var(--accent);
  font-style: italic;
  color: var(--fg-muted);
}

/* Drop cap — toggled onto whichever <p> the user picks (cursor position),
   not hardcoded to the first paragraph. */
.portfolio-item__text-content .gb-dropcap::first-letter {
  float: left;
  font-family: var(--font-display);
  font-size: 3.2em;
  line-height: 0.86;
  padding-right: 0.08em;
  padding-top: 0.02em;
}

/* Horizontal rule — thin subtle divider matching the dark aesthetic, not an
   unstyled browser default. Targets the bare element (not a class) so both
   toolbar-inserted (<hr class="gb-e-hr">) and paste-sanitized (bare <hr>,
   see PASTE_KEEP in editor.js) rules render identically. */
.portfolio-item__text-content hr {
  margin: 1.5em 0;
  border: none;
  border-top: 1px solid rgba(255,255,255,0.15);
}

/* ─────────────────────────────────────────────────
   SINGLE PORTFOLIO ITEM
───────────────────────────────────────────────── */
.portfolio-single {
  max-width: 1200px;
  margin: 0 auto;
  padding: 48px 32px 96px;
}

.portfolio-single__hero {
  width: 100%;
  max-height: 80vh;
  object-fit: cover;
  margin-bottom: 40px;
}

.portfolio-single__header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 24px;
  align-items: start;
  margin-bottom: 32px;
}

.portfolio-single__title {
  font-size: clamp(2rem, 6vw, 4rem);
  color: var(--fg);
}

.portfolio-single__details {
  text-align: right;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-muted);
  line-height: 2;
}

.portfolio-single__content {
  max-width: 680px;
  color: var(--fg-muted);
  line-height: 1.8;
}

/* ─────────────────────────────────────────────────
   BACK LINK
───────────────────────────────────────────────── */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin-bottom: 40px;
  transition: color var(--transition), gap var(--transition);
}

.back-link:hover { color: var(--fg); gap: 12px; opacity: 1; }
.back-link::before { content: '←'; }

/* ─────────────────────────────────────────────────
   EMPTY STATE
───────────────────────────────────────────────── */
.portfolio-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  text-align: center;
  gap: 16px;
}

.portfolio-empty__title {
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 300;
  color: var(--fg-muted);
}

.portfolio-empty__text {
  font-size: 0.85rem;
  color: var(--fg-muted);
  letter-spacing: 0.05em;
}

/* ─────────────────────────────────────────────────
   SITE FOOTER
───────────────────────────────────────────────── */
.site-footer {
  padding: 32px;
  border-top: 1px solid rgba(255,255,255,0.06);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-muted);
}

/* ─────────────────────────────────────────────────
   PAGE: About / Default
───────────────────────────────────────────────── */
.page-content {
  max-width: 720px;
  margin: 0 auto;
  padding: 64px 32px 96px;
}

.page-content h1 {
  font-size: clamp(2.5rem, 6vw, 4.5rem);
  margin-bottom: 40px;
  color: var(--accent);
}

.page-content p {
  color: var(--fg-muted);
  margin-bottom: 1.5em;
  line-height: 1.85;
}

/* ─────────────────────────────────────────────────
   RESPONSIVE
───────────────────────────────────────────────── */
/* Mobile breakpoint injected dynamically via wp_head (see gridenberg.php) */

@media (max-width: 640px) {
  .site-header { padding: 0 20px; }
  .site-nav { display: none; }
  .portfolio-item { grid-column: span 2 !important; grid-row: span 2 !important; }
}

/* ─────────────────────────────────────────────────
   LOADING ANIMATION
───────────────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.portfolio-item {
  animation: fadeUp 0.6s var(--transition) both;
}

.portfolio-item:nth-child(1)  { animation-delay: 0.05s; }
.portfolio-item:nth-child(2)  { animation-delay: 0.10s; }
.portfolio-item:nth-child(3)  { animation-delay: 0.15s; }
.portfolio-item:nth-child(4)  { animation-delay: 0.20s; }
.portfolio-item:nth-child(5)  { animation-delay: 0.25s; }
.portfolio-item:nth-child(6)  { animation-delay: 0.30s; }
.portfolio-item:nth-child(7)  { animation-delay: 0.35s; }
.portfolio-item:nth-child(8)  { animation-delay: 0.40s; }
.portfolio-item:nth-child(9)  { animation-delay: 0.45s; }
.portfolio-item:nth-child(10) { animation-delay: 0.50s; }

/* ─────────────────────────────────────────────────
   SCROLLBAR
───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: #333; border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: #555; }

/* ── v2 : figcaption sur les tuiles ── */
.portfolio-item {
  position: relative;  /* already set, renforcement */
}

.portfolio-item__caption {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 10px 14px;
  background: linear-gradient(transparent, rgba(0,0,0,0.7));
  font-size: 0.72rem;
  color: rgba(255,255,255,0.8);
  letter-spacing: 0.04em;
  pointer-events: none;
}

/* ─────────────────────────────────────────────────
   LIGHTBOX
───────────────────────────────────────────────── */
#gb-lb {
  display: none; position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,0.93);
  align-items: center; justify-content: center;
}
#gb-lb.is-open { display: flex; }

.gb-lb__stage {
  display: flex; flex-direction: column; align-items: center;
  max-width: 90vw; max-height: 90vh;
}
.gb-lb__img {
  max-width: 90vw; max-height: 82vh;
  object-fit: contain;
  opacity: 0; transition: opacity .25s;
}
.gb-lb__img.is-loaded { opacity: 1; }

.gb-lb__caption {
  margin-top: 12px; color: rgba(255,255,255,0.6);
  font-size: 13px; text-align: center;
}
.gb-lb__counter {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  /* was rgba(255,255,255,0.35) ≈ 3:1 against the near-black overlay —
     below the 4.5:1 WCAG AA minimum for text this size. 0.55 clears it
     comfortably (~6:1) while staying visually a "muted" indicator. */
  color: rgba(255,255,255,0.55); font-size: 12px; font-family: 'DM Mono', monospace;
}
.gb-lb__close {
  position: fixed; top: 20px; right: 24px;
  background: none; border: none; color: rgba(255,255,255,0.6);
  font-size: 22px; cursor: pointer; line-height: 1;
  transition: color .15s;
}
.gb-lb__close:hover { color: #fff; }

.gb-lb__nav {
  position: fixed; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: rgba(255,255,255,0.45);
  font-size: 48px; cursor: pointer; padding: 0 20px; line-height: 1;
  transition: color .15s; user-select: none;
}
.gb-lb__nav:hover { color: #fff; }
.gb-lb__prev { left: 0; }
.gb-lb__next { right: 0; }

.portfolio-item--lightbox { cursor: zoom-in; }

/* ─────────────────────────────────────────────────
   REDUCED MOTION
   Covers the fadeUp keyframe (grid items), all hover
   transitions (image brightness, overlay/title/meta
   reveal, header show/hide — including the header's
   transition set inline by main.js, which this
   !important still wins over), the lightbox image's
   fade-in, and smooth-scroll. Durations collapse to
   ~0 instead of `none` so elements still land on
   their final state rather than getting stuck
   mid-transition or never receiving it at all.
───────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0s !important;
    scroll-behavior: auto !important;
  }
}
