/*
Theme Name: Hugin
Theme URI: https://example.com/hugin
Author: Hugin
Author URI: https://example.com
Description: A minimal, dark, editorial portfolio theme for a design / branding studio. Full-width horizontal project rows, slide-out menu, scroll-reveal animations, hover image swap. Original theme inspired by modern studio websites.
Version: 1.0.0
Requires at least: 6.0
Tested up to: 6.6
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: hugin
*/

/* =========================================================
   0. Design tokens
   ========================================================= */
:root {
  --bg: #090a0a;
  --bg-soft: #101212;
  --text: #ccd5d6;
  --text-strong: #f2f5f5;
  --text-dim: rgba(204, 213, 214, 0.55);
  --text-faint: rgba(204, 213, 214, 0.35);
  --line: rgba(204, 213, 214, 0.12);
  --line-strong: rgba(204, 213, 214, 0.28);
  --accent: #e9ded0;            /* warm off-white accent */

  --container: 1400px;
  --gutter: clamp(20px, 5vw, 64px);

  --font-body: "General Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-head: "General Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;

  --step--1: clamp(0.78rem, 0.72rem + 0.3vw, 0.9rem);
  --step-0:  clamp(0.95rem, 0.9rem + 0.25vw, 1.05rem);
  --step-1:  clamp(1.2rem, 1rem + 1vw, 1.6rem);
  --step-2:  clamp(1.6rem, 1.2rem + 2vw, 2.8rem);
  --step-3:  clamp(2.2rem, 1.4rem + 4vw, 4.4rem);
  --step-4:  clamp(3rem, 1.5rem + 7vw, 8rem);

  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --dur: 0.7s;

  --header-h: 112px;
}

/* =========================================================
   1. Reset & base
   ========================================================= */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }

html {
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
  min-height: 100vh;
}

body.menu-open { overflow: hidden; }

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

a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }

h1, h2, h3, h4 {
  font-family: var(--font-head);
  font-weight: 500;
  line-height: 1.02;
  letter-spacing: -0.02em;
  color: var(--text-strong);
}

::selection { background: var(--accent); color: var(--bg); }

::-webkit-scrollbar { width: 9px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 20px; }

.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* =========================================================
   2. Header
   ========================================================= */
.site-header {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 100;
  height: var(--header-h);
  display: flex;
  align-items: center;
  background: rgba(9, 10, 10, 0.8);
  backdrop-filter: saturate(140%) blur(12px);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid transparent;
  transition: background 0.4s var(--ease), border-color 0.4s var(--ease);
}
.site-header.is-scrolled {
  background: rgba(9, 10, 10, 0.94);
  border-bottom-color: var(--line);
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 1.35rem;
  letter-spacing: -0.03em;
  color: #fff;
  line-height: 1;
}
.brand span { font-weight: 400; opacity: 0.7; }
.brand-logo {
  height: 64px;
  width: auto;
  display: block;
}
@media (max-width: 820px) {
  .brand-logo { height: 42px; }
}

.header-right {
  display: flex;
  align-items: center;
  gap: clamp(16px, 3vw, 40px);
}

.lang-switch {
  display: flex;
  gap: 14px;
  font-size: var(--step-1);
  letter-spacing: 0.02em;
  color: #fff;
  text-transform: uppercase;
}
.lang-switch li { display: inline-flex; }
.lang-switch a { opacity: 0.5; transition: opacity 0.3s var(--ease); }
.lang-switch a:hover,
.lang-switch a[aria-current="true"],
.lang-switch .current-lang a { opacity: 1; }

.menu-toggle {
  display: inline-flex;
  align-items: center;
  background: none;
  border: 0;
  padding: 0;
  color: #fff;
  font-family: var(--font-head);
  font-size: var(--step-1);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1;
  cursor: pointer;
}
.menu-toggle__words {
  position: relative;
  display: block;
  height: 1em;
  overflow: hidden;
}
.menu-toggle__now,
.menu-toggle__alt {
  display: block;
  transition: transform 0.45s var(--ease);
}
.menu-toggle__alt {
  position: absolute;
  top: 0;
  left: 0;
  transform: translateY(110%);
}
.menu-toggle:hover .menu-toggle__now { transform: translateY(-110%); }
.menu-toggle:hover .menu-toggle__alt { transform: translateY(0); }

/* =========================================================
   3. Slide-out menu
   ========================================================= */
.nav-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(9, 10, 10, 0.6);
  backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.5s var(--ease), visibility 0.5s;
}
body.menu-open .nav-overlay { opacity: 1; visibility: visible; }

.nav-panel {
  position: fixed;
  top: 0; right: 0;
  z-index: 95;
  height: 100vh;
  height: 100dvh;   /* mobile: match the VISIBLE viewport so the footer isn't hidden behind the URL bar */
  width: min(560px, 100vw);
  background: var(--bg-soft);
  border-left: 1px solid var(--line);
  padding: calc(var(--header-h) + 20px) var(--gutter) var(--gutter);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transform: translateX(100%);
  transition: transform 0.7s var(--ease);
  overflow-y: auto;
}
body.menu-open .nav-panel { transform: translateX(0); }

.nav-main li { overflow: hidden; }
.nav-main a {
  display: block;
  font-family: var(--font-head);
  font-weight: 500;
  font-size: clamp(2.2rem, 6vw, 3.6rem);
  letter-spacing: -0.03em;
  line-height: 1.25;
  color: var(--text-strong);
  transform: translateY(110%);
  transition: transform 0.7s var(--ease), color 0.3s;
}
body.menu-open .nav-main a { transform: translateY(0); }
.nav-main li:nth-child(1) a { transition-delay: 0.08s; }
.nav-main li:nth-child(2) a { transition-delay: 0.14s; }
.nav-main li:nth-child(3) a { transition-delay: 0.20s; }
.nav-main li:nth-child(4) a { transition-delay: 0.26s; }
.nav-main li:nth-child(5) a { transition-delay: 0.32s; }
.nav-main a:hover { color: var(--accent); }
.nav-main a .idx {
  font-size: 0.9rem;
  vertical-align: super;
  opacity: 0.4;
  margin-right: 10px;
  letter-spacing: 0;
}

.nav-foot {
  display: grid;
  /* auto-fit: collapses to ONE column on narrow phones (each column needs room for
     the email) — a full 560px desktop panel still shows two columns. */
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 24px 16px;
  padding-top: 32px;
  border-top: 1px solid var(--line);
  font-size: var(--step--1);
}
.nav-foot h4 {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-faint);
  font-weight: 500;
  margin-bottom: 12px;
}
.nav-foot a { color: var(--text-dim); transition: color 0.3s; overflow-wrap: anywhere; }
.nav-foot a:hover { color: var(--text-strong); }
.nav-foot li + li { margin-top: 6px; }

/* Phone numbers are left-to-right: isolate them so their digit groups keep the
   correct order inside RTL (Arabic) pages instead of rendering reversed. */
a[href^="tel:"] { direction: ltr; unicode-bidi: isolate; }

/* =========================================================
   4. Hero / intro
   ========================================================= */
.hero {
  padding-top: calc(var(--header-h) + clamp(16px, 5vh, 60px));
  padding-bottom: clamp(40px, 8vh, 90px);
}
.hero-eyebrow {
  font-size: var(--step--1);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--text-faint);
  margin-bottom: clamp(20px, 4vh, 40px);
  display: flex;
  gap: 14px;
  align-items: center;
}
.hero-eyebrow::before {
  content: "";
  width: 40px; height: 1px;
  background: var(--line-strong);
}
.hero-title {
  font-size: var(--step-3);
  max-width: 16ch;
  color: var(--text-strong);
}
.hero-title em {
  font-style: normal;
  color: var(--text-faint);
}
/* A4-style hero tagline — big animated wordmark, top-left, words rise in on load */
.hero-title--flight {
  max-width: none;
  white-space: nowrap;           /* keep the whole tagline on ONE line */
  /* vw-based so it always fits one line; measured coefficient ≈ 6.6vw fills ~95% of the hero width */
  font-size: clamp(1.25rem, 6.6vw, 6.25rem);
  line-height: 1;
  letter-spacing: -0.015em;
  text-transform: uppercase;
  color: var(--text-strong);
  font-weight: 500;
}
/* Arabic hero: connected script — no case transform, a touch more line room
   (the diacritics need it), and it inherits the page's RTL direction. */
body.rtl .hero-title--flight {
  text-transform: none;
  line-height: 1.1;
  letter-spacing: normal;
  /* Arabic is a shorter phrase, so it keeps the fuller display size and still fits one line
     (the English base shrank to ~6.6vw only to fit its longer 4-word line). */
  font-size: clamp(2.6rem, 8.5vw, 7rem);
}
.hero-title--flight .hero-word {
  display: inline-block;
  animation: heroFlightIn 0.95s var(--ease) both;
}
.hero-title--flight .hero-word:nth-child(1) { animation-delay: 0.12s; }
.hero-title--flight .hero-word:nth-child(2) { animation-delay: 0.24s; }
.hero-title--flight .hero-word:nth-child(3) { animation-delay: 0.36s; }
.hero-title--flight .hero-word:nth-child(4) { animation-delay: 0.48s; }
/* Hidden state lives in the keyframe, not the base rule — so if animations
   don't run, the words stay VISIBLE (never an invisible hero). */
@keyframes heroFlightIn {
  from { opacity: 0; transform: translateY(0.5em); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .hero-title--flight .hero-word { animation: none; opacity: 1; transform: none; }
}
.hero-meta {
  margin-top: clamp(24px, 5vh, 48px);
  display: flex;
  flex-wrap: wrap;
  gap: 12px 40px;
  font-size: var(--step--1);
  color: var(--text-dim);
  letter-spacing: 0.02em;
}

/* =========================================================
   5. Works — full-width horizontal project rows
   ========================================================= */
.works {
  padding-bottom: clamp(60px, 12vh, 160px);
}
.works-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 24px 0;
  border-top: 1px solid var(--line);
  color: var(--text-faint);
  font-size: var(--step--1);
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.project-card {
  display: grid;
  grid-template-columns: minmax(0, 42%) 1fr;
  align-items: center;
  gap: clamp(24px, 5vw, 80px);
  padding: clamp(28px, 4vw, 48px) 0;
  border-top: 1px solid var(--line);
  transition: padding 0.4s var(--ease);
}
.project-card:last-child { border-bottom: 1px solid var(--line); }

.project-card-media {
  position: relative;
  aspect-ratio: 12 / 7; /* ~1.71:1 — matches the reference card ratio */
  overflow: hidden;
  border-radius: 4px;
  background: var(--bg-soft);
}
.project-card-media img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.6s var(--ease), transform 1.2s var(--ease);
}
.project-card-media .pc-hover { opacity: 0; }
.project-card:hover .has-hover .pc-cover { opacity: 0; }
.project-card:hover .has-hover .pc-hover { opacity: 1; }
.project-card:hover .project-card-media img { transform: scale(1.04); }

.project-card-body { max-width: 40ch; }
.project-card-index {
  font-size: var(--step--1);
  color: var(--text-faint);
  letter-spacing: 0.05em;
  margin-bottom: 14px;
}
.project-card-title {
  font-size: var(--step-2);
  margin-bottom: 16px;
  transition: color 0.3s;
}
.project-card:hover .project-card-title { color: var(--accent); }
.project-card-cat {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}
.project-card-cat li {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  border: 1px solid var(--line);
  border-radius: 40px;
  padding: 5px 12px;
}
.project-card-desc {
  color: var(--text-dim);
  font-size: var(--step-0);
  line-height: 1.55;
}
.project-card-more {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 22px;
  font-size: var(--step--1);
  letter-spacing: 0.05em;
  color: var(--text-strong);
}
.project-card-more::after {
  content: "→";
  transition: transform 0.4s var(--ease);
}
.project-card:hover .project-card-more::after { transform: translateX(6px); }

.works-all {
  display: flex;
  justify-content: center;
  margin-top: clamp(50px, 10vh, 110px);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 18px 34px;
  border: 1px solid var(--line-strong);
  border-radius: 60px;
  font-family: var(--font-head);
  font-size: var(--step--1);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-strong);
  transition: background 0.4s var(--ease), color 0.4s var(--ease), border-color 0.4s;
}
.btn:hover { background: var(--accent); color: var(--bg); border-color: var(--accent); }

/* =========================================================
   6. Footer
   ========================================================= */
.site-footer {
  border-top: 1px solid var(--line);
  padding: clamp(60px, 12vh, 130px) 0 40px;
}
.footer-cta {
  font-size: var(--step-3);
  color: var(--text-strong);
  max-width: 18ch;
  margin-bottom: clamp(40px, 8vh, 90px);
}
.footer-cta a { color: var(--accent); }
.footer-grid {
  display: grid;
  /* 200px (was 160) so a 2-column layout only forms when a column is wide enough
     for the email — narrow phones (e.g. S23 Ultra ~384px) get a clean single column. */
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 40px 24px;
  padding-top: 40px;
  border-top: 1px solid var(--line);
}
.footer-grid h4 {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-faint);
  font-weight: 500;
  margin-bottom: 16px;
}
.footer-grid a { color: var(--text-dim); transition: color 0.3s; overflow-wrap: anywhere; }
.footer-grid a:hover { color: var(--text-strong); }
.footer-grid li + li { margin-top: 8px; }

/* Brand note. No `max-width` — the grid column already caps this at ~300px.
   Justified in both languages; hyphens:auto stops the narrow English column
   from opening ugly word gaps. */
.footer-about p {
  color: var(--text-dim);
  line-height: 1.8;
  font-size: var(--step--1);
  text-align: justify;
  -webkit-hyphens: auto;
  hyphens: auto;
}
.footer-about p + p { margin-top: 10px; }
.footer-about .footer-about-lead { color: var(--text-strong); }
.footer-bottom {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: clamp(50px, 10vh, 100px);
  color: var(--text-faint);
  font-size: var(--step--1);
}

/* =========================================================
   7. Scroll-reveal
   ========================================================= */
.appear-on-scroll {
  opacity: 0;
  transform: translateY(40px);
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
  will-change: opacity, transform;
}
.appear-on-scroll.is-visible {
  opacity: 1;
  transform: none;
}
@media (prefers-reduced-motion: reduce) {
  .appear-on-scroll { opacity: 1 !important; transform: none !important; }
  html { scroll-behavior: auto; }
  * { transition-duration: 0.001ms !important; }
}

/* =========================================================
   8. Generic pages (about / blog / single)
   ========================================================= */
.page-head {
  padding-top: calc(var(--header-h) + clamp(50px, 14vh, 160px));
  padding-bottom: clamp(30px, 6vh, 70px);
}
.page-head h1 { font-size: var(--step-4); }
.page-lead {
  max-width: 60ch;
  margin-top: 30px;
  font-size: var(--step-1);
  color: var(--text-dim);
  line-height: 1.4;
}
.prose { max-width: 68ch; }
.prose > * + * { margin-top: 1.2em; }
.prose h2 { font-size: var(--step-1); margin-top: 1.8em; }
.prose p { color: var(--text-dim); }
.prose a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

.single-hero { padding-top: calc(var(--header-h) + 40px); }
.single-hero img { width: 100%; border-radius: 6px; }

/* =========================================================
   9. Responsive
   ========================================================= */
@media (max-width: 820px) {
  :root { --header-h: 72px; }
  .project-card {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  .project-card-body { max-width: none; }
  .hero-title { max-width: none; }
  .nav-panel { width: 100vw; border-left: 0; }
  .footer-bottom { flex-direction: column; }
}

/* =========================================================
   10. RTL / Arabic (body.rtl is added automatically for the
   Arabic locale). Most layout already uses logical properties;
   these rules fix the physical bits + Arabic typography.
   ========================================================= */
body.rtl {
  --font-body: "IBM Plex Sans Arabic", "General Sans", "Helvetica Neue", sans-serif;
  --font-head: "IBM Plex Sans Arabic", "General Sans", "Helvetica Neue", sans-serif;
}

/* Arabic is a connected script: never letter-space or uppercase it. */
body.rtl h1, body.rtl h2, body.rtl h3, body.rtl h4,
body.rtl .brand, body.rtl .nav-main a, body.rtl .hero-title,
body.rtl .hero-eyebrow, body.rtl .hero-meta, body.rtl .menu-toggle,
body.rtl .works-head, body.rtl .btn, body.rtl .project-card-index,
body.rtl .project-card-cat li, body.rtl .project-card-more,
body.rtl .nav-foot h4, body.rtl .footer-grid h4, body.rtl .footer-cta,
body.rtl .footer-bottom, body.rtl .lang-switch {
  letter-spacing: normal;
}
body.rtl .hero-eyebrow, body.rtl .menu-toggle, body.rtl .works-head,
body.rtl .btn, body.rtl .project-card-cat li, body.rtl .nav-foot h4,
body.rtl .footer-grid h4 {
  text-transform: none;
}

/* Arabic justifies via inter-word spacing (not hyphenation — the Arabic script isn't hyphenated). */
body.rtl .footer-about p {
  text-justify: inter-word;
  -webkit-hyphens: none;
  hyphens: none;
}

/* Slide-out panel enters from the left in RTL. */
body.rtl .nav-panel {
  right: auto;
  left: 0;
  border-left: 0;
  border-right: 1px solid var(--line);
  transform: translateX(-100%);
}
body.rtl.menu-open .nav-panel { transform: translateX(0); }

/* Menu index number sits on the correct side. */
body.rtl .nav-main a .idx { margin-right: 0; margin-left: 10px; }

/* "View project" arrow flips direction. */
body.rtl .project-card-more::after { content: "\2190"; } /* ← */
body.rtl .project-card:hover .project-card-more::after { transform: translateX(-6px); }
