/* ============================================
   Custom Grid Homepage Styles
   Black & white with International Orange accent
   Polaroid-style tiles, square corners
   ============================================ */

/* ---- Classic Mac Font Faces ---- */
@font-face {
    font-family: 'Chicago';
    src: url('../fonts/classic-mac/Chicago-12.woff2') format('woff2'),
         url('../fonts/classic-mac/Chicago-12.woff') format('woff');
    font-weight: normal; font-style: normal; font-display: swap;
}
@font-face {
    font-family: 'Geneva';
    src: url('../fonts/classic-mac/Geneva12-Medium.woff2') format('woff2'),
         url('../fonts/classic-mac/Geneva12-Medium.woff') format('woff');
    font-weight: normal; font-style: normal; font-display: swap;
}
@font-face {
    font-family: 'NewYork';
    src: url('../fonts/classic-mac/NewYork10.woff2') format('woff2'),
         url('../fonts/classic-mac/NewYork10.woff') format('woff');
    font-weight: normal; font-style: normal; font-display: swap;
}
@font-face {
    font-family: 'NewYork';
    src: url('../fonts/classic-mac/NewYorkBold.woff2') format('woff2'),
         url('../fonts/classic-mac/NewYorkBold.woff') format('woff');
    font-weight: bold; font-style: normal; font-display: swap;
}
@font-face {
    font-family: 'ClassicCourier';
    src: url('../fonts/classic-mac/Courier-12.woff2') format('woff2'),
         url('../fonts/classic-mac/Courier-12.woff') format('woff');
    font-weight: normal; font-style: normal; font-display: swap;
}
@font-face {
    font-family: 'Cairo';
    src: url('../fonts/classic-mac/Cairo.woff2') format('woff2'),
         url('../fonts/classic-mac/Cairo.woff') format('woff');
    font-weight: normal; font-style: normal; font-display: swap;
}
@font-face {
    font-family: 'Palatino';
    src: url('../fonts/classic-mac/Palatino-12.woff2') format('woff2'),
         url('../fonts/classic-mac/Palatino-12.woff') format('woff');
    font-weight: normal; font-style: normal; font-display: swap;
}

/* ---- Classic Mac Font Class Mappings ---- */
.has-chicago-title:not([class*=" gh-font-heading"]):not([class^="gh-font-heading"]) :is(.is-title, .gh-content :is(h2, h3)) { font-family: 'Chicago', var(--font-sans); }
.has-geneva-title:not([class*=" gh-font-heading"]):not([class^="gh-font-heading"]) :is(.is-title, .gh-content :is(h2, h3)) { font-family: 'Geneva', var(--font-sans); }
.has-newyork-title:not([class*=" gh-font-heading"]):not([class^="gh-font-heading"]) :is(.is-title, .gh-content :is(h2, h3)) { font-family: 'NewYork', var(--font-serif); }
.has-cairo-title:not([class*=" gh-font-heading"]):not([class^="gh-font-heading"]) :is(.is-title, .gh-content :is(h2, h3)) { font-family: 'Cairo', var(--font-sans); }
.has-palatino-title:not([class*=" gh-font-heading"]):not([class^="gh-font-heading"]) :is(.is-title, .gh-content :is(h2, h3)) { font-family: 'Palatino', var(--font-serif); }
.has-classiccourier-title:not([class*=" gh-font-heading"]):not([class^="gh-font-heading"]) :is(.is-title, .gh-content :is(h2, h3)) { font-family: 'ClassicCourier', var(--font-mono); }
.has-chicago-body:not([class*=" gh-font-body"]):not([class^="gh-font-body"]) .is-body { font-family: 'Chicago', var(--font-sans); }
.has-geneva-body:not([class*=" gh-font-body"]):not([class^="gh-font-body"]) .is-body { font-family: 'Geneva', var(--font-sans); }
.has-newyork-body:not([class*=" gh-font-body"]):not([class^="gh-font-body"]) .is-body { font-family: 'NewYork', var(--font-serif); }
.has-cairo-body:not([class*=" gh-font-body"]):not([class^="gh-font-body"]) .is-body { font-family: 'Cairo', var(--font-sans); }
.has-palatino-body:not([class*=" gh-font-body"]):not([class^="gh-font-body"]) .is-body { font-family: 'Palatino', var(--font-serif); }
.has-classiccourier-body:not([class*=" gh-font-body"]):not([class^="gh-font-body"]) .is-body { font-family: 'ClassicCourier', var(--font-mono); }

/* ---- Accent color ---- */
:root {
    --accent-orange: #FF4F00;
}

/* ---- Square corners on navigation buttons ---- */
.gh-navigation .gh-button,
.gh-navigation a[data-portal="signin"],
.gh-navigation a[data-portal="signup"] {
    border-radius: 0;
}

/* ---- Container ---- */
.custom-grid-container {
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    padding: 0 20px 20px;
}

/* ---- Header: match background, reduce gap ---- */
.gh-header {
    margin-top: 20px;
    margin-bottom: 0;
    background-color: var(--background-color);
}

.gh-header.is-classic {
    background-color: var(--background-color);
    padding-block: 60px;
}

/* Remove the dark overlay on the header cover image */
.gh-header.is-classic.has-image::before {
    display: none;
}

/* Make the header image blend or hide so background matches */
.gh-header.is-classic.has-image .gh-header-image {
    display: none;
}

/* Ensure header text uses normal text color, not white */
.gh-header.is-classic .gh-header-inner {
    color: inherit;
}

.gh-header.is-classic.has-image .gh-header-inner {
    color: inherit;
}

/* ---- Hide default Ghost navigation on homepage and posts ---- */
body.home-template .gh-navigation,
body.post-template .gh-navigation,
body.page-template .gh-navigation {
    display: none;
}

/* ---- Hide Ghost's built-in Portal subscribe button ---- */
.gh-portal-triggerbtn-iframe {
    display: none !important;
}

/* ---- Top Bar: [+/- ^] | [filters] | [account] ---- */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 20px 0 25px;
}

.left-controls {
    display: flex;
    gap: 4px;
}

.bar-divider {
    width: 1px;
    height: 28px;
    background: #ccc;
    flex-shrink: 0;
}

.type-filters {
    display: flex;
    gap: 8px;
    flex-wrap: nowrap;
}

.right-account {
    display: flex;
}

.account-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    color: inherit;
    background: none;
    border: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: opacity 0.2s;
}

.account-icon {
    width: 24px;
    height: 24px;
    display: block;
    flex-shrink: 0;
}

.account-btn:hover {
    opacity: 0.7;
}

body.dark-mode .account-icon {
    filter: invert(1);
}

/* ---- Filter Buttons ---- */

.type-filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.type-filter-btn {
    width: 48px;
    height: 48px;
    border: none;
    background: none;
    border-radius: 0;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    -webkit-tap-highlight-color: transparent;
}

.type-filter-btn:hover {
    transform: translateY(-2px);
    opacity: 0.7;
}

.type-filter-btn img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: pixelated;
}

.type-filter-btn.active {
    background: rgba(255, 79, 0, 0.1);
    border-radius: 8px;
}

/* ---- Grid/Sort Controls ---- */

.grid-btn {
    width: 48px;
    height: 48px;
    border: none;
    background: none;
    border-radius: 0;
    cursor: pointer;
    color: inherit;
    transition: color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    aspect-ratio: 1;
    padding: 0;
}

.grid-icon {
    width: 24px;
    height: 24px;
    display: block;
    flex-shrink: 0;
}

.grid-btn:hover {
    opacity: 0.7;
}

.grid-btn:focus {
    outline: none;
}

.sort-toggle {
    width: 48px;
    height: 48px;
    border: none;
    background: none;
    border-radius: 0;
    cursor: pointer;
    color: inherit;
    transition: opacity 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    padding: 0;
}

.sort-icon {
    width: 24px;
    height: 24px;
    display: block;
    flex-shrink: 0;
}

.sort-toggle:hover {
    opacity: 0.7;
}

.sort-toggle:focus {
    outline: none;
}

body.dark-mode .grid-icon,
body.dark-mode .sort-icon {
    filter: invert(1);
}

/* ---- Post Grid ---- */
.post-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 20px;
    width: 100%;
}

.post-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.post-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.post-grid.cols-1 { grid-template-columns: 1fr; }

/* ---- Tiles: square image + info below ---- */
.post-tile {
    position: relative;
    border-radius: 0;
    cursor: pointer;
    overflow: visible;
    transition: transform 0.2s ease;
    container-type: inline-size;
}

.post-tile:hover {
    transform: translateY(-4px);
}

.post-tile:focus-visible {
    outline: 2px solid var(--accent-orange);
    outline-offset: 2px;
}

.post-tile.hidden { display: none; }

/* Square image area */
.tile-image {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
}

.tile-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Placeholder when no feature image */
.tile-image-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background: rgba(128, 128, 128, 0.1);
}

.tile-image-placeholder img {
    width: 40%;
    height: 40%;
    object-fit: contain;
    image-rendering: pixelated;
    opacity: 0.3;
}

/* Info area below the image */
.tile-overlay {
    position: relative;
    padding: 8px 2px 0;
    pointer-events: none;
}

.tile-overlay-top {
    display: none;
}

.tile-overlay-bottom {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.tile-overlay-bottom-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.post-title {
    font-size: 14px;
    font-size: 6.67cqi;
    font-weight: 600;
    color: inherit;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.post-date {
    font-size: 11px;
    font-size: 5.24cqi;
    color: inherit;
    opacity: 0.5;
    white-space: nowrap;
}

.post-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.post-icon img {
    width: 16px;
    width: 7.6cqi;
    height: 16px;
    height: 7.6cqi;
    object-fit: contain;
    image-rendering: pixelated;
    opacity: 0.5;
}

/* No posts */
.no-posts {
    text-align: center;
    padding: 60px 20px;
    color: #666;
    font-size: 16px;
}

/* ---- Responsive ---- */
@media (max-width: 1200px) {
    .post-grid:not(.cols-3):not(.cols-2):not(.cols-1) { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 900px) {
    .post-grid:not(.cols-3):not(.cols-2):not(.cols-1) { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 600px) {
    /* On mobile, cap the default to 2 columns */
    .post-grid:not(.cols-3):not(.cols-2):not(.cols-1) { grid-template-columns: repeat(2, 1fr); }
    .post-grid.cols-3 { grid-template-columns: repeat(2, 1fr); }
    .top-bar {
        gap: 0;
        padding: 12px 0;
        margin-left: calc(-50vw + 50%);
        margin-right: calc(-50vw + 50%);
        width: 100vw;
        box-sizing: border-box;
        justify-content: space-evenly;
    }
    .left-controls {
        gap: 0;
        display: contents;
    }
    .type-filters {
        gap: 0;
        display: contents;
    }
    .right-account {
        display: contents;
    }
    .bar-divider { display: block; height: 22px; width: 1px; flex-shrink: 0; }
    .type-filter-btn { width: 38px; height: 38px; padding: 6px; }
    .grid-btn, .sort-toggle, .account-btn { width: 38px; height: 38px; }
    .grid-icon, .sort-icon { width: 22px; height: 22px; }
    .account-icon { width: 22px; height: 22px; }
    .custom-grid-container { padding: 0 10px 10px; }
}
@media (max-width: 400px) {
    .type-filter-btn { width: 34px; height: 34px; padding: 5px; }
    .grid-btn, .sort-toggle, .account-btn { width: 34px; height: 34px; }
    .grid-icon, .sort-icon { width: 20px; height: 20px; }
    .account-icon { width: 20px; height: 20px; }
}

/* ---- Hide hamburger menu ---- */
.gh-burger {
    display: none !important;
}

/* ---- Dark Mode Toggle Button ---- */
.gh-darkmode-toggle {
    cursor: pointer;
    background: none;
    border: none;
    color: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
}

body.dark-mode .gh-darkmode-toggle svg {
    display: none;
}

body.dark-mode .gh-darkmode-toggle::after {
    content: '';
    display: block;
    width: 18px;
    height: 18px;
    background: currentColor;
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z'/%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z'/%3E%3C/svg%3E");
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
}

/* ---- Dark Mode ---- */
body.dark-mode {
    background-color: #1a1a1a !important;
    color: #e0e0e0;
}

body.dark-mode .gh-viewport {
    background-color: #1a1a1a;
}

body.dark-mode .gh-navigation,
body.dark-mode .gh-navigation-inner,
body.dark-mode .gh-navigation-brand,
body.dark-mode .gh-navigation-actions,
body.dark-mode .gh-navigation-members {
    background-color: #111 !important;
    color: #e0e0e0;
}

body.dark-mode .gh-navigation a,
body.dark-mode .gh-navigation .gh-icon-button,
body.dark-mode .gh-navigation button {
    color: #e0e0e0;
}

body.dark-mode .controls {
    background: transparent;
}

body.dark-mode .type-filter-btn {
    background: none;
}

body.dark-mode .type-filter-btn:hover {
    opacity: 0.7;
}

body.dark-mode .type-filter-btn.active {
    background: rgba(255, 79, 0, 0.15);
}

/* SVG icon color flip in dark mode */
body.dark-mode .type-filter-btn img,
body.dark-mode .tile-image-placeholder img {
    filter: invert(1);
}

body.dark-mode .bar-divider {
    background: #555;
}

body.dark-mode .post-tile {
    background: transparent;
}

body.dark-mode .tile-image {
    background: transparent;
}

body.dark-mode .post-icon img {
    filter: invert(1);
}

body.dark-mode .no-posts {
    color: #999;
}

body.dark-mode .gh-header,
body.dark-mode .gh-header.is-classic {
    background-color: #1a1a1a !important;
}

body.dark-mode .gh-header .gh-header-inner {
    color: #e0e0e0;
}

body.dark-mode .gh-header-title,
body.dark-mode .gh-header-description {
    color: #e0e0e0 !important;
}

body.dark-mode .gh-button {
    background-color: var(--accent-orange);
    color: white !important;
    border-color: var(--accent-orange);
}

body.dark-mode .gh-navigation .gh-button {
    background-color: var(--accent-orange);
    color: white !important;
}

body.dark-mode .gh-cta {
    background-color: #222 !important;
    color: #e0e0e0 !important;
}

body.dark-mode .gh-cta-title,
body.dark-mode .gh-cta-description {
    color: #e0e0e0 !important;
}
