@import url('https://fonts.googleapis.com/css2?family=Jost:wght@400;700&display=swap');

:root {
    --bg: #000000;
    --bg-rgb: 0, 0, 0;
    --text: #ffffff;
    --text-rgb: 255, 255, 255;
    --support-strong: #111111;
    --support-muted: #333333;
    --placeholder-text: var(--support-muted);
    
    --spacing: 1rem; 
    --universal-padding: 1rem;
    --site-gutter: var(--spacing);
    --type-gap: var(--spacing);

    --fs-name: 2rem; 
    --fs-h1: var(--fs-name);
    --fs-h2: 1.5rem;
    --fs-h3: 1.25rem;
    --fs-body: 1rem;
    
    --overlay-height: calc(var(--fs-name) + (2 * var(--universal-padding))); 
    
    --header-height: calc(var(--overlay-height) + (2 * var(--spacing)));

    --lh-header: 1.1;
    --lh-body: 1.5;
    --br-ui: 12px;
    --icon-stroke: 2.5;
}

@media (prefers-color-scheme: light) {
    :root {
        --bg: #ffffff;
        --bg-rgb: 255, 255, 255;
        --text: #000000;
        --text-rgb: 0, 0, 0;
        --support-strong: #eeeeee;
        --support-muted: #999999;
        --placeholder-text: var(--support-muted);
    }
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    /* Absolute No-Animation Policy */
    transition: none !important;
    animation: none !important;
}

html {
    height: 100%;
    overflow-y: auto;
    background-color: var(--bg);
    color-scheme: dark;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}

@media (prefers-color-scheme: light) {
    html {
        color-scheme: light;
    }
}

/* Hide scrollbar for Chrome, Safari and Opera */
::-webkit-scrollbar {
    display: none;
}

body {
    min-height: 100%;
    background-color: var(--bg);
    color: var(--text);
    font-family: 'Jost', sans-serif;
    font-feature-settings: "ss01" 0;
    -webkit-font-feature-settings: "ss01" 0;
    line-height: var(--lh-body);
    overflow-x: hidden;
    padding-top: var(--header-height); 
}

body.page-open {
    overflow-x: hidden;
}

/* Typography System */
h1, h2, h3 {
    line-height: var(--lh-header);
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: var(--type-gap);
}

h1 { font-size: var(--fs-h1); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); }

p, .body, ul, ol {
    font-size: var(--fs-body);
    font-weight: 400;
    line-height: var(--lh-body);
    margin-bottom: var(--type-gap);
}

ul, ol {
    padding-left: 1.5rem;
}

ul {
    list-style-type: disc;
}

ul ul {
    list-style-type: circle;
}

li {
    margin-bottom: 0.5rem;
}

li:last-child {
    margin-bottom: 0;
}

/* Inline Formatting */
strong { font-weight: 700; }
em { font-style: italic; }
del { text-decoration: line-through; }
ins, u {
    text-decoration: underline;
    text-underline-offset: 4px;
    text-decoration-thickness: 0.12em;
}

/* Inline & Text Links */
.block-text a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-thickness: 0.12em;
    display: inline-flex;
    align-items: baseline;
    gap: 0.3em;
}

.external-icon {
    width: 0.85em;
    height: 0.85em;
    stroke: currentColor;
    stroke-width: var(--icon-stroke);
    flex-shrink: 0;
    position: relative;
    top: 0.05em; /* Optical alignment */
}

/* Code Blocks */
code {
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9em;
    background-color: rgba(var(--text-rgb), 0.1);
    padding: 0.2em 0.4em;
    border-radius: 4px;
}

pre {
    background-color: rgba(var(--text-rgb), 0.05);
    padding: var(--universal-padding);
    margin-bottom: var(--type-gap);
    overflow-x: auto;
    border-radius: var(--br-ui);
}

pre code {
    background-color: transparent;
    padding: 0;
}

.header-system {
    position: fixed;
    top: var(--site-gutter);
    left: 0;
    right: 0;
    z-index: 2000;
    display: flex;
    justify-content: space-between;
    padding: 0 var(--spacing);
    pointer-events: none;
}

.header-system * {
    pointer-events: auto;
}

#site-name {
    /* High-Intensity Balanced Blur */
    height: var(--overlay-height);
    display: inline-flex;
    align-items: center;
    padding: 0 var(--universal-padding);
    background-color: transparent;
    backdrop-filter: blur(30px) saturate(400%) brightness(1.1);
    -webkit-backdrop-filter: blur(30px) saturate(400%) brightness(1.1);
    color: var(--text);
    text-decoration: none;
    font-size: var(--fs-name);
    font-weight: 700;
    border-radius: var(--br-ui);
    border: none;
    outline: none;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

#contact-overlay {
    width: var(--overlay-height);
    padding: 0;
}

.btn, .btn-mini {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background-color: transparent;
    backdrop-filter: blur(30px) saturate(400%) brightness(1.1);
    -webkit-backdrop-filter: blur(30px) saturate(400%) brightness(1.1);
    border-radius: var(--br-ui);
    cursor: pointer;
    border: none;
    overflow: hidden;
}

.btn {
    height: var(--overlay-height);
    padding: 0 var(--universal-padding);
    font-size: var(--fs-name);
    font-weight: 700;
    text-decoration: none;
}

.btn::before, .btn-mini::before {
    content: "";
    position: absolute;
    inset: 0;
    background-color: var(--text);
    -webkit-mask-size: 1.1em, cover;
    -webkit-mask-repeat: no-repeat, no-repeat;
    -webkit-mask-position: center, center;
    -webkit-mask-composite: destination-out;
    mask-composite: exclude;
    pointer-events: none;
}

#contact-overlay::before {
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect width='20' height='16' x='2' y='4' rx='2'/%3E%3Cpath d='m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7'/%3E%3C/svg%3E"), linear-gradient(#000, #000);
    -webkit-mask-size: 1.2em, cover;
}

.btn-mini {
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
}

.btn-mini::before {
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='15 3 21 3 21 9'/%3E%3Cpolyline points='9 21 3 21 3 15'/%3E%3Cline x1='21' y1='3' x2='14' y2='10'/%3E%3Cline x1='3' y1='21' x2='10' y2='14'/%3E%3C/svg%3E"), linear-gradient(#000, #000);
    -webkit-mask-size: 1.2rem, cover;
}

.btn-mini.is-exit::before {
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='4 14 10 14 10 20'/%3E%3Cpolyline points='20 10 14 10 14 4'/%3E%3Cline x1='14' y1='10' x2='21' y2='3'/%3E%3Cline x1='3' y1='21' x2='10' y2='14'/%3E%3C/svg%3E"), linear-gradient(#000, #000);
}

.btn-mini.is-back::before {
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m12 19-7-7 7-7'/%3E%3Cpath d='M19 12H5'/%3E%3C/svg%3E"), linear-gradient(#000, #000);
}

.btn svg, .btn-mini svg {
    display: none;
}

/* Base Link Reset */
a {
    color: inherit;
    text-decoration: none;
}

/* Core Components */
#grid,
.sub-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0;
    width: 100%;
    background-color: var(--bg);
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

.item {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    background-color: transparent;
    border-radius: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.theme-invert {
    filter: none;
}

@media (prefers-color-scheme: dark) {
    .theme-invert.is-bright:not(.is-transparent) {
        filter: invert(1) hue-rotate(180deg);
    }

    .theme-invert.is-dark.is-transparent {
        filter: invert(1) hue-rotate(180deg) brightness(0.85) contrast(1.5);
    }
}

@media (prefers-color-scheme: light) {
    .theme-invert.is-dark:not(.is-transparent) {
        filter: invert(1) hue-rotate(180deg);
    }

    .theme-invert.is-bright.is-transparent {
        filter: invert(1) hue-rotate(180deg) brightness(0.85) contrast(1.5);
    }
}

.item.loading {
    background-color: var(--support-strong);
}

.item img, 
.item .thumb-video,
.block-media img,
.block-media video,
.block-media model-viewer,
.block-media iframe {
    width: 100%;
    height: 100%;
    display: block;
    opacity: 1;
    transition: opacity 0.4s ease;
}

.item img, .item .thumb-video {
    object-fit: cover;
}

.item.loading img, 
.item.loading .thumb-video,
.block-media.image-loading img,
.block-media.loading video,
.block-media.loading iframe,
.model-container.loading model-viewer {
    opacity: 0;
}

.item .thumb-video {
    pointer-events: none; /* Non-interactable in grid */
}

.item model-viewer {
    width: 100%;
    height: 100%;
    --poster-color: transparent;
    outline: none;
    display: block;
    position: relative;
    z-index: 1;
    opacity: 1;
    transition: opacity 420ms ease !important;
    pointer-events: none; /* Non-interactable in grid */
}

.item.loading model-viewer {
    opacity: 0;
}

model-viewer::part(default-progress-bar) {
    display: none;
}

.placeholder-404 {
    width: 100%;
    height: 100%;
    background-color: var(--support-strong);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing);
    color: var(--placeholder-text);
    font-size: clamp(1.25rem, 4vw, 2rem);
    font-weight: 700;
    letter-spacing: 0.1em;
    text-align: center;
    text-transform: uppercase;
}

.placeholder-title {
    width: 100%;
    height: 100%;
    background-color: var(--support-strong);
    color: var(--placeholder-text);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing);
    text-align: center;
    font-size: clamp(1.25rem, 4vw, 2rem);
    font-weight: 700;
    line-height: var(--lh-header);
    overflow-wrap: break-word; /* Wraps at spaces; only mid-word if a single word is wider than the container */
    word-break: normal;
    text-transform: uppercase;
}

#page {
    display: none;
    width: 100%;
    min-height: 100vh;
    background-color: var(--bg);
}

#page > :not(.page-back-layer):not(.back-cursor) {
    cursor: auto;
}

#page .page-back-layer {
    z-index: 5;
    cursor: none;
}

#page .page-back-layer.is-side {
    position: fixed;
    top: 0;
    bottom: 0;
    width: 15vw;
}

#page .page-back-layer.is-left {
    left: 0;
}

#page .page-back-layer.is-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: var(--header-height);
}

/* Basic Table Support */
.block-text table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-bottom: var(--type-gap);
    font-size: 0.9em;
    border-radius: var(--br-ui);
    border: 1px solid var(--support-muted);
    overflow: hidden;
}

.block-text th, .block-text td {
    border-bottom: 1px solid var(--support-muted);
    border-right: 1px solid var(--support-muted);
    padding: 0.5rem;
    text-align: left;
}

.block-text th:last-child, 
.block-text td:last-child {
    border-right: none;
}

.block-text tr:last-child th,
.block-text tr:last-child td {
    border-bottom: none;
}

.block-text th {
    background-color: rgba(var(--text-rgb), 0.05);
    font-weight: 700;
}

.back-cursor {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 2001;
    pointer-events: none;
    opacity: 0;
    transform: translate3d(-100px, -100px, 0);
    will-change: transform;
}

.back-cursor.is-visible {
    opacity: 1;
}

/* Page Title Slash Styling */
h1 .title-slash {
    color: var(--placeholder-text);
    margin: 0 0.2em;
}

h1 .title-part {
    cursor: pointer;
}

/* Model Visual Tuning */
model-viewer {
    filter: saturate(1.05);
}

/* Iframe Loading State */
.iframe-wrapper {
    position: relative;
    width: 100%;
}

.iframe-wrapper iframe {
    position: relative;
    z-index: 2;
}

.page-content {
    position: relative;
    z-index: 1000;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    margin-bottom: var(--header-height); /* Create scroll space to reveal fixed footer */
    cursor: auto;
    background: var(--bg);
}

/* Page Blocks */
/* Page Media Blocks */
.block-media {
    width: 100%;
    margin-bottom: var(--spacing);
    padding: 0 var(--spacing);
}

.block-media img, 
.block-media video, 
.block-media model-viewer,
.block-media iframe {
    display: block;
    position: relative;
    z-index: 1;
}

.model-container model-viewer {
    opacity: 1;
    transition: opacity 420ms ease !important;
}

.model-container.loading model-viewer {
    opacity: 0;
}

@media (prefers-reduced-motion: reduce) {
    .item model-viewer,
    .model-container model-viewer {
        transition: none !important;
    }
}

.block-media img, 
.block-media video, 
.block-media model-viewer,
.block-media iframe,
.block-media .placeholder-404 {
    width: 100%;
    height: auto;
    border-radius: var(--br-ui);
    overflow: hidden;
    border: none;
}

.block-media .placeholder-404 {
    background-color: var(--support-strong);
}

.block-media model-viewer,
.block-media iframe,
.block-media .placeholder-404 {
    aspect-ratio: 16 / 9; /* Standard for video/model embeds */
}

.model-container {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    background: var(--bg);
    border-radius: var(--br-ui);
    overflow: hidden;
}

.model-container:fullscreen {
    aspect-ratio: auto;
    border-radius: 0;
}

/* Base Button Logic Re-Standardized Above */

.fullscreen-btn {
    position: absolute;
    bottom: var(--spacing);
    right: var(--spacing);
    z-index: 10;
}

.model-container:fullscreen .fullscreen-btn {
    bottom: var(--spacing);
    right: var(--spacing);
}

.block-text {
    width: 100%;
    padding: 0 var(--spacing);
    margin-bottom: var(--spacing);
}

.block-spec {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 var(--spacing);
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--spacing);
    margin-bottom: var(--spacing);
}

.block-split {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 var(--spacing);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing);
    margin-bottom: var(--spacing);
}

.block-split img, 
.block-split video,
.block-split iframe {
    width: 100%;
    height: auto;
    display: block;
    border-radius: var(--br-ui);
    overflow: hidden;
}

@media (max-width: 600px) {
    .block-split {
        grid-template-columns: 1fr;
    }
}

.link-line {
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 4px;
    text-decoration-thickness: 0.12em;
    color: inherit;
    display: inline-block;
}

/* Responsive constraints: 2 to 5 columns */
@media (min-width: 600px) {
    #grid,
    .sub-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 900px) {
    #grid,
    .sub-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (min-width: 1400px) {
    #grid,
    .sub-grid { grid-template-columns: repeat(5, 1fr); }
}
