/* ============================================================
   HADI INTERIOR DESIGN — Global Stylesheet
   VERSION: 2.0.0
   WCAG 2.1 AA Compliant
   ============================================================ */

/* --- Reset & Base ------------------------------------------ */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Colour palette — warm neutrals + accent */
    --color-bg:        #0e0e0e;
    --color-surface:   #161616;
    --color-text:      #f0ece4;
    --color-muted:     #9a938a;
    --color-accent:    #c8a96e;
    --color-border:    rgba(200, 169, 110, 0.2);

    /* Typography */
    --font-heading: "Playfair Display", Georgia, serif;
    --font-body:    "Inter", Helvetica, Arial, sans-serif;

    /* Spacing scale (4‑px grid) */
    --space-xs:  0.25rem;
    --space-sm:  0.5rem;
    --space-md:  1rem;
    --space-lg:  2rem;
    --space-xl:  4rem;
    --space-2xl: 8rem;

    /* Transitions */
    --ease-out:   cubic-bezier(0.22, 1, 0.36, 1);
    --duration:   0.5s;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-body);
    color: var(--color-text);
    background: var(--color-bg);
    line-height: 1.6;
    overflow-x: hidden;
}

/* --- Typography -------------------------------------------- */
h1, h2, h3, h4 {
    font-family: var(--font-heading);
    font-weight: 400;
    line-height: 1.15;
    letter-spacing: -0.02em;
}

h1 { font-size: clamp(2.4rem, 5vw, 4.5rem); }
h2 { font-size: clamp(1.8rem, 3.5vw, 3rem); }
h3 { font-size: clamp(1.2rem, 2vw, 1.75rem); }

p {
    max-width: 60ch;
    color: var(--color-muted);
}

a {
    color: var(--color-accent);
    text-decoration: none;
    transition: color var(--duration) var(--ease-out);
}

a:hover {
    color: var(--color-text);
}

/* --- Utility ----------------------------------------------- */
.container {
    width: 90%;
    max-width: 1200px;
    margin-inline: auto;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
}

/* --- Skip Link (WCAG 2.4.1) ------------------------------- */
.skip-link {
    position: fixed;
    top: -100%;
    left: var(--space-md);
    z-index: 200;
    padding: var(--space-sm) var(--space-md);
    background: var(--color-accent);
    color: var(--color-bg);
    font-size: 0.85rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    border-radius: 0 0 4px 4px;
    text-decoration: none;
    transition: top 0.2s ease;
}

.skip-link:focus {
    top: 0;
    outline: 2px solid var(--color-text);
    outline-offset: 2px;
}

/* --- Focus Indicators (WCAG 2.4.7) ------------------------ */
:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 3px;
}

a:focus-visible,
button:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 3px;
}

/* --- Accessibility Widget (WCAG 2.2.2 + 1.4.4 + 1.4.3) --- */
.a11y-widget {
    position: fixed;
    bottom: var(--space-lg);
    right: var(--space-lg);
    z-index: 150;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: var(--space-sm);
}

/* Trigger — universal accessibility icon */
.a11y-widget__trigger {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border: 1px solid var(--color-border);
    border-radius: 50%;
    background: rgba(14, 14, 14, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: var(--color-accent);
    cursor: pointer;
    transition: background var(--duration) var(--ease-out),
                border-color var(--duration) var(--ease-out),
                transform 0.2s var(--ease-out);
}

.a11y-widget__trigger:hover {
    background: rgba(14, 14, 14, 1);
    border-color: var(--color-accent);
}

.a11y-widget__trigger:active {
    transform: scale(0.93);
}

.a11y-widget--open .a11y-widget__trigger {
    border-color: var(--color-accent);
}

/* Panel — slides up from the trigger */
.a11y-widget__panel {
    width: 260px;
    padding: var(--space-md);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: rgba(22, 22, 22, 0.96);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
    animation: a11ySlideUp 0.25s var(--ease-out);
}

.a11y-widget__panel[hidden] {
    display: none;
}

.a11y-widget__heading {
    font-family: var(--font-heading);
    font-size: 0.95rem;
    font-weight: 400;
    color: var(--color-text);
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid var(--color-border);
    outline: none;
}

/* Row — each control */
.a11y-widget__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-xs) 0;
    min-height: 36px;
}

.a11y-widget__label {
    font-size: 0.8rem;
    color: var(--color-muted);
    cursor: pointer;
}

/* Toggle switch */
.a11y-widget__toggle {
    position: relative;
    width: 38px;
    height: 20px;
    flex-shrink: 0;
}

.a11y-widget__checkbox {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    cursor: pointer;
    z-index: 1;
}

.a11y-widget__slider {
    position: absolute;
    inset: 0;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.12);
    transition: background 0.25s var(--ease-out);
}

.a11y-widget__slider::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--color-muted);
    transition: transform 0.25s var(--ease-out),
                background 0.25s var(--ease-out);
}

.a11y-widget__checkbox:checked + .a11y-widget__slider {
    background: var(--color-accent);
}

.a11y-widget__checkbox:checked + .a11y-widget__slider::after {
    transform: translateX(18px);
    background: var(--color-bg);
}

.a11y-widget__checkbox:focus-visible + .a11y-widget__slider {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

/* Text-size controls */
.a11y-widget__row--text {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-xs);
    padding-top: var(--space-sm);
}

.a11y-widget__row--text .a11y-widget__label {
    cursor: default;
}

.a11y-widget__text-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-sm);
}

.a11y-widget__size-btn {
    flex: 1;
    padding: var(--space-xs) 0;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    background: transparent;
    color: var(--color-text);
    font-size: 0.8rem;
    font-family: var(--font-body);
    cursor: pointer;
    transition: background 0.2s var(--ease-out),
                border-color 0.2s var(--ease-out);
    min-height: 32px;
}

.a11y-widget__size-btn:hover {
    background: rgba(200, 169, 110, 0.12);
    border-color: var(--color-accent);
}

.a11y-widget__size-display {
    flex: 1;
    text-align: center;
    font-size: 0.75rem;
    color: var(--color-muted);
    font-variant-numeric: tabular-nums;
}

/* Reset button */
.a11y-widget__reset {
    display: block;
    width: 100%;
    margin-top: var(--space-sm);
    padding: var(--space-xs) 0;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    background: transparent;
    color: var(--color-muted);
    font-size: 0.75rem;
    font-family: var(--font-body);
    cursor: pointer;
    transition: color 0.2s var(--ease-out),
                border-color 0.2s var(--ease-out);
    min-height: 32px;
}

.a11y-widget__reset:hover {
    color: var(--color-accent);
    border-color: var(--color-accent);
}

@keyframes a11ySlideUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- High Contrast Mode ------------------------------------ */
.high-contrast {
    --color-bg:      #000000;
    --color-surface: #0a0a0a;
    --color-text:    #ffffff;
    --color-muted:   #e0e0e0;
    --color-accent:  #ffd700;
    --color-border:  rgba(255, 215, 0, 0.4);
}

/* --- Reduce Motion (widget toggle) ------------------------- */
.reduce-motion *,
.reduce-motion *::before,
.reduce-motion *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
}

.reduce-motion .hero__tagline,
.reduce-motion .hero__title,
.reduce-motion .hero__subtitle,
.reduce-motion .hero__cta {
    opacity: 1;
    transform: none;
    animation: none;
}

.accent {
    color: var(--color-accent);
}

/* --- Three.js Canvas Layer --------------------------------- */
#scene-container {
    position: fixed;
    inset: 0;
    z-index: -1;
    overflow: hidden;
}

#scene-container canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* Overlay gradient so UI stays readable over 3D scene */
.scene-overlay {
    position: fixed;
    inset: 0;
    z-index: 0;
    background: linear-gradient(
        180deg,
        rgba(14, 14, 14, 0.55) 0%,
        rgba(14, 14, 14, 0.85) 100%
    );
    pointer-events: none;
}

/* --- Navigation -------------------------------------------- */
.site-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) var(--space-lg);
    transition: background var(--duration) var(--ease-out);
}

.site-nav.scrolled {
    background: rgba(14, 14, 14, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.site-nav__logo {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    color: var(--color-text);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.site-nav__links {
    display: flex;
    gap: var(--space-lg);
    list-style: none;
}

.site-nav__links a {
    font-size: 0.85rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--color-muted);
    position: relative;
    transition: color var(--duration) var(--ease-out);
}

.site-nav__links a::after {
    content: "";
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 1px;
    background: var(--color-accent);
    transition: width var(--duration) var(--ease-out);
}

.site-nav__links a:hover,
.site-nav__links a.active {
    color: var(--color-text);
}

.site-nav__links a:hover::after,
.site-nav__links a.active::after {
    width: 100%;
}

/* Mobile toggle */
.nav-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: var(--space-sm);
}

.nav-toggle span {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--color-text);
    margin: 5px 0;
    transition: transform var(--duration) var(--ease-out),
                opacity var(--duration) var(--ease-out);
}

/* --- Hero Section ------------------------------------------ */
.hero {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    padding: var(--space-2xl) var(--space-lg);
}

.hero__tagline {
    font-size: 0.8rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--color-accent);
    margin-bottom: var(--space-md);
    opacity: 0;
    transform: translateY(20px);
    animation: fadeUp 0.8s var(--ease-out) 0.3s forwards;
}

.hero__title {
    margin-bottom: var(--space-md);
    opacity: 0;
    transform: translateY(30px);
    animation: fadeUp 0.8s var(--ease-out) 0.5s forwards;
}

.hero__subtitle {
    font-size: 1.1rem;
    line-height: 1.7;
    margin-bottom: var(--space-xl);
    opacity: 0;
    transform: translateY(30px);
    animation: fadeUp 0.8s var(--ease-out) 0.7s forwards;
}

.hero__cta {
    display: inline-block;
    padding: var(--space-sm) var(--space-lg);
    border: 1px solid var(--color-accent);
    color: var(--color-accent);
    font-size: 0.8rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    transition: background var(--duration) var(--ease-out),
                color var(--duration) var(--ease-out);
    opacity: 0;
    transform: translateY(30px);
    animation: fadeUp 0.8s var(--ease-out) 0.9s forwards;
}

.hero__cta:hover {
    background: var(--color-accent);
    color: var(--color-bg);
}

/* --- Sections ---------------------------------------------- */
.section {
    position: relative;
    z-index: 1;
    padding: var(--space-2xl) var(--space-lg);
}

.section__label {
    font-size: 0.75rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--color-accent);
    margin-bottom: var(--space-sm);
}

.section__title {
    margin-bottom: var(--space-lg);
}

.section__divider {
    width: 60px;
    height: 1px;
    background: var(--color-border);
    margin-bottom: var(--space-lg);
}

/* --- Portfolio Grid ---------------------------------------- */
.portfolio-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: var(--space-lg);
}

.portfolio-card {
    position: relative;
    overflow: hidden;
    border-radius: 2px;
    aspect-ratio: 4 / 3;
    background: var(--color-surface);
    cursor: pointer;
}

.portfolio-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.8s var(--ease-out);
}

.portfolio-card:hover img,
.portfolio-card:focus-within img {
    transform: scale(1.05);
}

.portfolio-card:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 3px;
}

.portfolio-card__overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: var(--space-lg);
    background: linear-gradient(
        0deg,
        rgba(14, 14, 14, 0.8) 0%,
        transparent 60%
    );
    opacity: 0;
    transition: opacity var(--duration) var(--ease-out);
}

.portfolio-card:hover .portfolio-card__overlay,
.portfolio-card:focus .portfolio-card__overlay,
.portfolio-card:focus-within .portfolio-card__overlay {
    opacity: 1;
}

.portfolio-card__title {
    font-size: 1.1rem;
    color: var(--color-text);
}

.portfolio-card__category {
    font-size: 0.75rem;
    color: var(--color-accent);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* --- Legal / Policy Content -------------------------------- */
.legal-content {
    max-width: 70ch;
}

.legal-content p {
    margin-bottom: var(--space-md);
    line-height: 1.8;
}

.legal-content p:last-child {
    margin-bottom: 0;
}

.legal-content strong {
    color: var(--color-text);
    font-weight: 500;
}

.legal-content ul {
    list-style: none;
    padding-left: 0;
    margin-top: var(--space-sm);
    margin-bottom: var(--space-md);
}

.legal-content ul li {
    position: relative;
    padding-left: var(--space-lg);
    margin-bottom: var(--space-sm);
    color: var(--color-muted);
    line-height: 1.8;
}

.legal-content ul li::before {
    content: "";
    position: absolute;
    top: 0.7em;
    left: 0;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--color-accent);
}

.legal-content code {
    font-size: 0.9em;
    padding: 0.15em 0.4em;
    border-radius: 3px;
    background: rgba(200, 169, 110, 0.1);
    color: var(--color-accent);
}

.legal-content a {
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* --- Footer ------------------------------------------------ */
.site-footer {
    position: relative;
    z-index: 1;
    padding: var(--space-xl) var(--space-lg);
    border-top: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
    text-align: center;
    font-size: 0.75rem;
    color: var(--color-text);
}

.site-footer a {
    color: var(--color-accent);
}

.site-footer a:hover {
    color: var(--color-text);
}

/* --- Keyframes --------------------------------------------- */
@keyframes fadeUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* --- Responsive -------------------------------------------- */
@media (max-width: 768px) {
    .site-nav__links {
        position: fixed;
        top: 0;
        right: -100%;
        width: 70%;
        height: 100vh;
        flex-direction: column;
        justify-content: center;
        gap: var(--space-xl);
        padding: var(--space-xl);
        background: var(--color-bg);
        transition: right var(--duration) var(--ease-out);
    }

    .site-nav__links.open {
        right: 0;
    }

    .nav-toggle {
        display: block;
        z-index: 110;
    }

    .nav-toggle.active span:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
    }

    .nav-toggle.active span:nth-child(2) {
        opacity: 0;
    }

    .nav-toggle.active span:nth-child(3) {
        transform: rotate(-45deg) translate(5px, -5px);
    }

    .hero {
        padding: var(--space-xl) var(--space-md);
    }

    .section {
        padding: var(--space-xl) var(--space-md);
    }

    .a11y-widget {
        bottom: var(--space-md);
        right: var(--space-md);
    }

    .a11y-widget__panel {
        width: calc(100vw - var(--space-lg) * 2);
        max-width: 280px;
    }
}

/* --- Reduced Motion (WCAG 2.3.3) -------------------------- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .hero__tagline,
    .hero__title,
    .hero__subtitle,
    .hero__cta {
        opacity: 1;
        transform: none;
        animation: none;
    }
}

/* --- Footer nav (WCAG landmark) ---------------------------- */
.site-footer nav {
    display: block;
}

.site-footer nav a {
    color: var(--color-accent);
}

.site-footer nav a:hover {
    color: var(--color-text);
}
