/* === Fonts === */
@font-face {
    font-family: 'Philosopher';
    src: url('fonts/Philosopher-Bold.woff2') format('woff2');
    font-weight: 700;
    font-display: swap;
}

@font-face {
    font-family: 'Sora';
    src: url('fonts/Sora.woff2') format('woff2');
    font-weight: 400 600;
    font-display: swap;
}

@font-face {
    font-family: 'JetBrains Mono';
    src: url('fonts/JetBrainsMono.woff2') format('woff2');
    font-weight: 400 500;
    font-display: swap;
}

/* === Colour Tokens === */
:root {
    --bg-page:        #f5f4f7;
    --bg-card:        #ffffff;
    --border:         #d8d5de;
    --border-subtle:  #eae8ee;
    --text-heading:   #1a1720;
    --text-primary:   #3a3644;
    --text-secondary: #6b6678;
    --text-body:      #4a4655;
    --text-muted:     #9b96a6;
    --accent-teal:    #0fa890;
    --accent-amber:   #c48a20;
    --text-on-accent: #0d0c0f;
    /* Derived tints — auto-adapt to theme since they reference the accent vars above */
    --accent-teal-subtle:  color-mix(in srgb, var(--accent-teal)  10%, transparent);
    --accent-teal-border:  color-mix(in srgb, var(--accent-teal)  20%, transparent);
    --accent-amber-border: color-mix(in srgb, var(--accent-amber) 30%, transparent);
    --t: 80ms cubic-bezier(0.05, 0.85, 0.1, 1);
    --theme-speed: 500ms;
}

[data-theme="dark"] {
    --bg-page:        #0d0c0f;
    --bg-card:        #18161c;
    --border:         #2d2a34;
    --border-subtle:  #211f27;
    --text-heading:   #e2dfe8;
    --text-primary:   #c4c0ce;
    --text-secondary: #7b7688;
    --text-body:      #5e5a66;
    --text-muted:     #3a3644;
    --accent-teal:    #5ee6d0;
    --accent-amber:   #f0b860;
    --text-on-accent: #0d0c0f;
}

/* === Theme transition (Native View Transitions API) === */
  ::view-transition-old(root),
  ::view-transition-new(root) {
      animation-duration: 0.8s;
      animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/* === Reset === */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:is(.filter-btn, .button-link, .theme-toggle, .amazon-link, .sort-button):focus-visible {
    outline: 2px solid var(--accent-teal);
    outline-offset: 2px;
    border-radius: 2px;
}

body {
    background: var(--bg-page);
    color: var(--text-primary);
    font-family: 'Sora', -apple-system, BlinkMacSystemFont, sans-serif;
    line-height: 1.6;
}

/* === Top gradient bar === */
.top-bar {
    height: 2px;
    background: linear-gradient(to right, var(--accent-teal), var(--accent-amber));
    opacity: 0.6;
}

/* === Container === */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px 48px;
}

/* === Trust bar === */
.trust-bar {
    display: flex;
    gap: 20px;
    margin-bottom: 28px;
    flex-wrap: wrap;
    font-size: 0.6875rem;
    color: var(--text-muted);
}

/* === Page nav (back link + theme toggle) === */
.page-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
}

.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    font-family: 'Sora', sans-serif;
    font-size: 0.6875rem;
    color: var(--text-muted);
    padding: 0;
    transition: color var(--t);
}

.theme-toggle:hover {
    color: var(--text-secondary);
}

/* === Header === */
header {
    margin-bottom: 24px;
}

h1 {
    font-family: 'Philosopher', serif;
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--text-heading);
    letter-spacing: -0.01em;
    margin-bottom: 10px;
}

.subtitle {
    font-size: 0.875rem;
    color: var(--text-body);
    max-width: 480px;
    line-height: 1.65;
}

.meta-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.meta-info__left {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.meta-affiliate {
    font-size: 0.6875rem;
    color: var(--text-muted);
    text-align: right;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.6875rem;
    color: var(--text-muted);
}

.meta-item strong {
    color: var(--text-secondary);
    font-weight: 600;
}

/* === Stats bar (4-column single card) === */
.stats-bar {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 3px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    margin-bottom: 16px;
}

.stat-item {
    padding: 20px;
    border-right: 1px solid var(--border);
}

.stat-item:last-child {
    border-right: none;
}

.stat-label {
    font-size: 0.6rem;
    font-weight: 600;
    color: var(--text-body);
    text-transform: uppercase;
    letter-spacing: 0.14em;
    margin-bottom: 8px;
}

.stat-value {
    font-family: 'Philosopher', serif;
    font-size: 1.55rem;
    font-weight: 700;
    color: var(--accent-teal);
    margin-bottom: 4px;
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}

.stat-value--amber {
    color: var(--accent-amber);
}

.stat-description {
    font-size: 0.6875rem;
    color: var(--text-body);
}

/* === Filters panel (two-column layout) === */
.filters-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 20px 0;
    margin-bottom: 16px;
    display: flex;
}

.filter-group {
    flex: 1;
    padding: 0 20px;
}

.filter-group:first-child {
    border-right: 1px solid var(--border);
}

.filter-label {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-body);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 10px;
    line-height: 1.75;
}

.filter-buttons {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 5px 13px;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: 2px;
    font-size: 0.74rem;
    font-weight: 400;
    cursor: pointer;
    font-family: 'Sora', sans-serif;
    line-height: 1.5;
    transition: border-color var(--t), color var(--t), background var(--t);
}

.filter-btn:hover {
    border-color: var(--accent-teal);
    color: var(--text-primary);
}

.filter-btn.active {
    background: var(--accent-teal);
    border-color: var(--accent-teal);
    color: var(--text-on-accent);
}

/* === Best Value badge (inline pill via ::after) === */
/* SSD/HDD: badge on col 2 (Product Name). GPU: badge on col 3 (Vendor shifts columns). */
.best-value-row td:nth-child(2),
.hardware-table--gpu .best-value-row td:nth-child(3) {
    position: relative;
    padding-right: 100px !important;
}

.best-value-row td:nth-child(2)::after,
.hardware-table--gpu .best-value-row td:nth-child(3)::after {
    content: "Best Value";
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    padding: 3px 7px;
    background: var(--accent-teal-subtle);
    color: var(--accent-teal);
    border: 1px solid var(--accent-teal-border);
    font-size: 0.55rem;
    font-weight: 600;
    border-radius: 2px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    white-space: nowrap;
    font-family: 'Sora', sans-serif;
}

/* GPU: suppress badge on col 2 (Brand) and reset its padding */
.hardware-table--gpu .best-value-row td:nth-child(2) {
    padding-right: 16px !important;
}

.hardware-table--gpu .best-value-row td:nth-child(2)::after {
    content: none;
}

/* === Table wrapper === */
.table-wrapper {
    overflow-x: auto;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 3px;
}

/* === Table === */
.hardware-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.hardware-table thead {
    border-bottom: 2px solid var(--border);
}

.hardware-table th {
    text-align: left;
    padding: 12px 16px;
    font-weight: 600;
    color: var(--text-body);
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.13em;
    white-space: nowrap;
}

.hardware-table th.sortable {
    cursor: pointer;
    user-select: none;
    padding: 0; /* Remove padding here so button can expand */
}

/* New native sort button inside th for A11Y */
.hardware-table th .sort-button {
    all: unset;
    cursor: pointer;
    font: inherit;
    color: inherit;
    display: inline-flex;
    align-items: center;
    width: 100%;
    padding: 12px 16px;
    box-sizing: border-box;
}

/* Stacked sort indicators (always visible) */
.hardware-table th .sort-indicators {
    display: inline-flex;
    flex-direction: column;
    margin-left: 4px;
    vertical-align: middle;
    gap: 1px;
}

.hardware-table th .sort-indicators .arrow-up,
.hardware-table th .sort-indicators .arrow-down {
    display: block;
    font-size: 0.42rem;
    line-height: 1;
    color: var(--text-muted);
}

/* Active sort column — teal header + active arrow */
.hardware-table th.sort-asc,
.hardware-table th.sort-desc {
    color: var(--accent-teal);
}

.hardware-table th.sort-asc .sort-indicators .arrow-up,
.hardware-table th.sort-desc .sort-indicators .arrow-down {
    color: var(--accent-teal);
}

.hardware-table tbody tr {
    border-bottom: 1px solid var(--border-subtle);
}

.hardware-table tbody tr:hover {
    background: var(--bg-page);
}

.hardware-table tbody tr.out-of-stock {
    opacity: 0.5;
    filter: grayscale(1);
}

.hardware-table tbody tr.out-of-stock:hover {
    background: transparent;
}

.hardware-table tbody tr:last-child {
    border-bottom: none;
}

.hardware-table td {
    padding: 15px 16px;
    color: var(--text-primary);
}

/* Product name column — heading colour */
.hardware-table--ssd td:nth-child(2),
.hardware-table--hdd td:nth-child(2),
.hardware-table--gpu td:nth-child(3) {
    color: var(--text-heading);
}

/* Secondary info columns (type, purpose, form factor) */
.hardware-table--ssd td:nth-child(4),
.hardware-table--ssd td:nth-child(5),
.hardware-table--hdd td:nth-child(4),
.hardware-table--hdd td:nth-child(5),
.hardware-table--gpu td:nth-child(2),
.hardware-table--gpu td:nth-child(5),
.hardware-table--gpu td:nth-child(6) {
    color: var(--text-secondary);
}

/* Numeric columns — JetBrains Mono */
.hardware-table--ssd td:nth-child(3),
.hardware-table--ssd td:nth-child(6),
.hardware-table--ssd td:nth-child(7),
.hardware-table--hdd td:nth-child(3),
.hardware-table--hdd td:nth-child(6),
.hardware-table--gpu td:nth-child(4),
.hardware-table--gpu td:nth-child(6),
.hardware-table--gpu td:nth-child(7) {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 400;
    font-size: 0.78rem;
    font-variant-numeric: tabular-nums;
}

/* Value metric columns (£/TB, £/score) — teal + mono */
.hardware-table .price-per-tb,
.hardware-table .price-per-score {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 500;
    color: var(--accent-teal);
    font-variant-numeric: tabular-nums;
}

/* Price column */
.hardware-table .price-amount {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 400;
    font-variant-numeric: tabular-nums;
}

/* === View on Amazon link (amber outline) === */
.amazon-link {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    padding: 5px 13px;
    background: transparent;
    color: var(--accent-amber);
    text-decoration: none;
    border-radius: 2px;
    font-family: 'Sora', sans-serif;
    border: 1px solid var(--accent-amber-border);
    white-space: nowrap;
    transition: border-color var(--t);
}

.amazon-link:hover {
    border-color: var(--accent-amber);
}

.amazon-link__main {
    font-size: 0.72rem;
    font-weight: 400;
    line-height: 1.3;
}

.amazon-link__sub {
    font-size: 0.58rem;
    font-weight: 400;
    color: var(--text-muted);
    line-height: 1.2;
}

/* === Button link (← Overview) === */
.button-link {
    display: inline-block;
    padding: 6px 15px;
    background: transparent;
    color: var(--text-secondary);
    text-decoration: none;
    border: 1px solid var(--border);
    border-radius: 2px;
    font-size: 0.76rem;
    font-weight: 400;
    font-family: 'Sora', sans-serif;
    transition: border-color var(--t), color var(--t);
}

.button-link:hover {
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

/* === Footer === */
footer {
    margin-top: 40px;
    padding-top: 16px;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

footer p {
    font-family: 'Sora', sans-serif;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 0;
}

footer a {
    font-family: 'Sora', sans-serif;
    font-size: 0.6875rem;
    color: var(--text-muted);
    text-decoration: none;
    transition: color var(--t);
}

footer a:hover {
    color: var(--text-secondary);
}

/* === About disclaimer box === */
.about-disclaimer {
    margin: 40px 0;
    padding: 20px 24px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 3px;
}

/* === About contact section === */
.about-contact {
    margin-top: 40px;
    padding-top: 32px;
    border-top: 1px solid var(--border);
}

/* === About page content styles === */
.about-content h2,
.about-disclaimer h2,
.about-contact h2 {
    font-family: 'Philosopher', serif;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-heading);
    margin: 28px 0 8px;
}

.about-content h2:first-child,
.about-disclaimer h2,
.about-contact h2 {
    margin-top: 0;
}

.about-content h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 20px 0 6px;
}

.about-content p,
.about-disclaimer p,
.about-contact p {
    color: var(--text-body);
    font-size: 0.875rem;
    line-height: 1.7;
    margin-bottom: 12px;
}

.about-content a:not(.amazon-link),
.about-contact a:not(.amazon-link) {
    color: var(--accent-teal);
    text-decoration: none;
}

.about-content a:not(.amazon-link):hover,
.about-contact a:not(.amazon-link):hover {
    text-decoration: underline;
}

.about-content code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8em;
    color: var(--text-primary);
    background: var(--border-subtle);
    padding: 1px 5px;
    border-radius: 2px;
}

/* === Homepage === */
body.home {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.container--home {
    max-width: 540px;
    text-align: center;
    width: 100%;
}

body.home h1 {
    font-family: 'Philosopher', serif;
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--text-heading);
    letter-spacing: -0.01em;
    margin-bottom: 8px;
}

body.home .subtitle {
    color: var(--text-secondary);
    max-width: none;
    margin-bottom: 24px;
}

.categories {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.category-card {
    background: var(--bg-card);
    padding: 20px 24px;
    border-radius: 3px;
    text-decoration: none;
    color: inherit;
    border: 1px solid var(--border);
    text-align: left;
    transition: border-color var(--t), transform var(--t);
}

.category-card:hover {
    border-color: var(--accent-teal);
    transform: translateY(-2px);
}

.category-card h2 {
    font-family: 'Philosopher', serif;
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--text-heading);
}

.category-card p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.coming-soon {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

.coming-soon:hover {
    transform: none;
    border-color: var(--border);
}

.badge {
    display: inline-block;
    background: var(--accent-teal-subtle);
    color: var(--accent-teal);
    border: 1px solid var(--accent-teal-border);
    padding: 2px 8px;
    border-radius: 2px;
    font-size: 0.58rem;
    font-weight: 600;
    margin-left: 6px;
    vertical-align: middle;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-family: 'Sora', sans-serif;
}

body.home footer {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-subtle);
    justify-content: center;
}

/* === Homepage theme toggle placement === */
.home-nav {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 24px;
}

/* === Responsive === */
@media (max-width: 900px) {
    .stats-bar {
        grid-template-columns: repeat(2, 1fr);
    }

    .stat-item:nth-child(2) {
        border-right: none;
    }

    .stat-item:nth-child(3) {
        border-top: 1px solid var(--border);
        border-right: 1px solid var(--border);
    }

    .stat-item:nth-child(4) {
        border-top: 1px solid var(--border);
        border-right: none;
    }
}

@media (max-width: 768px) {
    h1 {
        font-size: 1.75rem;
    }

    .container {
        padding: 20px 16px 40px;
    }

    .filters-panel {
        flex-direction: column;
        padding: 16px 0;
    }

    .filter-group:first-child {
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding-bottom: 16px;
    }

    .filter-group:last-child {
        padding-top: 16px;
    }

    .hardware-table th,
    .hardware-table td {
        padding: 10px 12px;
        font-size: 0.75rem;
    }

    .hardware-table th {
        font-size: 0.58rem;
    }

    .amazon-link {
        padding: 4px 10px;
    }

    .amazon-link__main {
        font-size: 0.68rem;
    }

    .amazon-link__sub {
        font-size: 0.55rem;
    }

    .best-value-row td:nth-child(2) {
        padding-right: 12px !important;
    }

    .best-value-row td:nth-child(2)::after {
        position: static;
        transform: none;
        display: inline-block;
        margin-left: 6px;
        vertical-align: middle;
    }

    .hardware-table--gpu .best-value-row td:nth-child(3) {
        padding-right: 12px !important;
    }

    .hardware-table--gpu .best-value-row td:nth-child(3)::after {
        position: static;
        transform: none;
        display: inline-block;
        margin-left: 6px;
        vertical-align: middle;
    }
}

@media (max-width: 480px) {
    .stats-bar {
        grid-template-columns: 1fr;
    }

    .stat-item {
        border-right: none !important;
        border-bottom: 1px solid var(--border);
    }

    .stat-item:last-child {
        border-bottom: none;
    }

    .stat-item:nth-child(3) {
        border-top: none;
    }
}
