/* ══════════════════════════════════════════════════════════════
   Räknare.se — Design System
   Pure CSS, zero frameworks, Lighthouse 100 optimized
   ══════════════════════════════════════════════════════════════ */

/* ── CSS Custom Properties ── */
:root {
    --primary: #1e3a5f;
    --primary-light: #2a5082;
    --accent: #0d9488;
    --accent-light: #14b8a6;
    --accent-glow: rgba(13, 148, 136, 0.15);

    --bg: #fafaf9;
    --bg-card: #ffffff;
    --bg-hero: linear-gradient(135deg, #1e3a5f 0%, #0f2640 100%);
    --bg-section: #f0f4f8;

    --text: #1a1a2e;
    --text-light: #64748b;
    --text-on-primary: #ffffff;
    --heading: #0f172a;

    --border: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
    --shadow-card: 0 2px 8px rgba(0,0,0,0.06);

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --max-w: 1100px;
    --transition: 0.2s ease;
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.7;
    font-size: 1rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-light); }

h1, h2, h3, h4 {
    color: var(--heading);
    line-height: 1.3;
    font-weight: 700;
}

h1 { font-size: clamp(1.8rem, 4vw, 2.5rem); }
h2 { font-size: clamp(1.4rem, 3vw, 1.8rem); margin-top: 2.5rem; margin-bottom: 1rem; }
h3 { font-size: 1.15rem; margin-top: 1.5rem; margin-bottom: 0.5rem; }

p { margin-bottom: 1rem; }

/* ── Header ── */
.site-header {
    background: var(--primary);
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0,0,0,0.15);
}

.header-inner {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.site-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-on-primary);
    font-weight: 800;
    font-size: 1.3rem;
    text-decoration: none;
}

.site-logo .logo-icon {
    width: 32px;
    height: 32px;
    background: var(--accent);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.nav-links {
    display: flex;
    gap: 0.3rem;
    list-style: none;
}

.nav-links a {
    color: rgba(255,255,255,0.85);
    padding: 0.45rem 0.9rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition);
}

.nav-links a:hover,
.nav-links a.active {
    color: #fff;
    background: rgba(255,255,255,0.12);
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-on-primary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem;
}

/* ── Hero Section ── */
.hero {
    background: var(--bg-hero);
    padding: 4rem 1.5rem 3.5rem;
    text-align: center;
    color: var(--text-on-primary);
}

.hero h1 {
    color: #fff;
    font-size: clamp(2rem, 5vw, 3rem);
    margin-bottom: 0.75rem;
    font-weight: 800;
}

.hero p {
    font-size: 1.15rem;
    opacity: 0.9;
    max-width: 600px;
    margin: 0 auto 2rem;
    line-height: 1.6;
}

.hero-search {
    max-width: 480px;
    margin: 0 auto;
    position: relative;
}

.hero-search input {
    width: 100%;
    padding: 0.9rem 1.2rem 0.9rem 3rem;
    border-radius: 50px;
    border: 2px solid rgba(255,255,255,0.2);
    background: rgba(255,255,255,0.1);
    color: #fff;
    font-size: 1rem;
    font-family: var(--font);
    backdrop-filter: blur(10px);
    transition: all var(--transition);
}

.hero-search input::placeholder { color: rgba(255,255,255,0.5); }
.hero-search input:focus {
    outline: none;
    border-color: var(--accent);
    background: rgba(255,255,255,0.15);
}

.hero-search .search-icon {
    position: absolute;
    left: 1.1rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.1rem;
    opacity: 0.6;
}

/* ── Container ── */
.container {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* ── Section ── */
.section {
    padding: 3.5rem 0;
}

.section-title {
    text-align: center;
    margin-bottom: 0.5rem;
}

.section-subtitle {
    text-align: center;
    color: var(--text-light);
    margin-bottom: 2.5rem;
    font-size: 1.05rem;
}

/* ── Category Grid ── */
.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.25rem;
}

.category-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.8rem 1.5rem;
    text-align: center;
    text-decoration: none;
    color: var(--text);
    transition: all 0.3s ease;
    box-shadow: var(--shadow-sm);
}

.category-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--accent);
    color: var(--text);
}

.category-card .card-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 1rem;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
}

.category-card h3 {
    font-size: 1.1rem;
    margin-bottom: 0.4rem;
    color: var(--heading);
    margin-top: 0;
}

.category-card p {
    font-size: 0.88rem;
    color: var(--text-light);
    margin: 0;
    line-height: 1.5;
}

/* Category card color variants */
.cat-matematik .card-icon { background: #ede9fe; color: #7c3aed; }
.cat-halsa .card-icon { background: #dcfce7; color: #16a34a; }
.cat-ekonomi .card-icon { background: #fef3c7; color: #d97706; }
.cat-tid .card-icon { background: #dbeafe; color: #2563eb; }
.cat-omvandlare .card-icon { background: #fce7f3; color: #db2777; }

/* ── Tool Cards Grid ── */
.tool-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.25rem;
}

.tool-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.4rem;
    text-decoration: none;
    color: var(--text);
    transition: all 0.25s ease;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}

.tool-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--accent);
    color: var(--text);
}

.tool-card .tool-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    background: var(--accent-glow);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.tool-card h4 {
    font-size: 1rem;
    margin-bottom: 0.2rem;
    color: var(--heading);
}

.tool-card p {
    font-size: 0.85rem;
    color: var(--text-light);
    margin: 0;
    line-height: 1.4;
}

/* ── Calculator Box ── */
.calc-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-md);
    margin-bottom: 2.5rem;
}

.calc-box h2 {
    margin-top: 0;
    margin-bottom: 1.5rem;
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.calc-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.calc-tab {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: 50px;
    background: var(--bg);
    color: var(--text-light);
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    font-family: var(--font);
    transition: all var(--transition);
}

.calc-tab:hover { border-color: var(--accent); color: var(--text); }
.calc-tab.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.calc-form {
    display: grid;
    gap: 1rem;
}

.form-group { display: flex; flex-direction: column; gap: 0.35rem; }

.form-group label {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--heading);
}

.form-group input,
.form-group select {
    padding: 0.7rem 1rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    transition: border-color var(--transition);
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.calc-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.btn-calc {
    padding: 0.8rem 2rem;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font);
    transition: all var(--transition);
    margin-top: 0.5rem;
}

.btn-calc:hover { background: var(--accent-light); transform: translateY(-1px); }

.calc-result {
    margin-top: 1.5rem;
    padding: 1.2rem 1.5rem;
    background: var(--accent-glow);
    border-radius: var(--radius);
    border-left: 4px solid var(--accent);
    display: none;
}

.calc-result.show { display: block; }

.calc-result .result-label {
    font-size: 0.85rem;
    color: var(--text-light);
    font-weight: 500;
    margin-bottom: 0.3rem;
}

.calc-result .result-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--accent);
}

/* ── Article Content (for tool pages) ── */
.page-content {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 2.5rem 1.5rem 4rem;
}

.breadcrumb {
    font-size: 0.88rem;
    color: var(--text-light);
    margin-bottom: 1.5rem;
}

.breadcrumb a { color: var(--accent); font-weight: 500; }
.breadcrumb span { margin: 0 0.3rem; }

.article-body {
    max-width: 780px;
}

.article-body p {
    font-size: 1.05rem;
    line-height: 1.8;
    color: var(--text);
}

.article-body h2 {
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border);
}

.article-body ul, .article-body ol {
    padding-left: 1.5rem;
    margin-bottom: 1rem;
}

.article-body li {
    margin-bottom: 0.4rem;
    line-height: 1.7;
}

.article-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    font-size: 0.95rem;
}

.article-body th, .article-body td {
    padding: 0.7rem 1rem;
    border: 1px solid var(--border);
    text-align: left;
}

.article-body th {
    background: var(--bg-section);
    font-weight: 600;
    color: var(--heading);
}

.article-body tr:nth-child(even) { background: var(--bg); }

/* Info/tip boxes */
.info-box {
    padding: 1.2rem 1.5rem;
    border-radius: var(--radius);
    margin: 1.5rem 0;
    font-size: 0.95rem;
    line-height: 1.6;
}

.info-box.tip {
    background: #ecfdf5;
    border-left: 4px solid #10b981;
    color: #065f46;
}

.info-box.warning {
    background: #fffbeb;
    border-left: 4px solid #f59e0b;
    color: #78350f;
}

/* FAQ Section */
.faq-section { margin-top: 2.5rem; }

.faq-item {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
    overflow: hidden;
}

.faq-question {
    width: 100%;
    padding: 1rem 1.2rem;
    background: var(--bg-card);
    border: none;
    text-align: left;
    font-size: 1rem;
    font-weight: 600;
    color: var(--heading);
    cursor: pointer;
    font-family: var(--font);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background var(--transition);
}

.faq-question:hover { background: var(--bg-section); }
.faq-question::after { content: '+'; font-size: 1.3rem; color: var(--accent); }
.faq-item.open .faq-question::after { content: '−'; }

.faq-answer {
    padding: 0 1.2rem;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
}

.faq-item.open .faq-answer {
    padding: 0 1.2rem 1rem;
    max-height: 500px;
}

/* ── Sidebar (related tools) ── */
.sidebar-links {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-top: 2rem;
}

.sidebar-links h3 {
    margin-top: 0;
    font-size: 1.05rem;
    margin-bottom: 1rem;
}

.sidebar-links ul {
    list-style: none;
    padding: 0;
}

.sidebar-links li {
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--border);
}

.sidebar-links li:last-child { border-bottom: none; }

.sidebar-links a {
    font-weight: 500;
    font-size: 0.92rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ── Footer ── */
.site-footer {
    background: var(--primary);
    color: rgba(255,255,255,0.8);
    padding: 3rem 1.5rem 1.5rem;
    margin-top: auto;
}

.footer-inner {
    max-width: var(--max-w);
    margin: 0 auto;
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 2.5rem;
}

.footer-brand h3 {
    color: #fff;
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
    margin-top: 0;
}

.footer-brand p {
    font-size: 0.88rem;
    line-height: 1.6;
    opacity: 0.8;
}

.footer-col h4 {
    color: #fff;
    font-size: 0.95rem;
    margin-bottom: 0.8rem;
    margin-top: 0;
}

.footer-col ul {
    list-style: none;
    padding: 0;
}

.footer-col li { margin-bottom: 0.4rem; }

.footer-col a {
    color: rgba(255,255,255,0.7);
    font-size: 0.88rem;
    transition: color var(--transition);
}

.footer-col a:hover { color: #fff; }

.footer-bottom {
    max-width: var(--max-w);
    margin: 2rem auto 0;
    padding-top: 1.2rem;
    border-top: 1px solid rgba(255,255,255,0.15);
    text-align: center;
    font-size: 0.82rem;
    opacity: 0.6;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .nav-links { display: none; }
    .nav-links.open {
        display: flex;
        flex-direction: column;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--primary);
        padding: 0.5rem;
        box-shadow: var(--shadow-lg);
    }
    .mobile-menu-btn { display: block; }

    .hero { padding: 2.5rem 1.5rem 2rem; }
    .category-grid { grid-template-columns: repeat(2, 1fr); }
    .tool-grid { grid-template-columns: 1fr; }
    .calc-row { grid-template-columns: 1fr; }
    .footer-inner { grid-template-columns: 1fr; gap: 1.5rem; }
    .calc-box { padding: 1.3rem; }
}

@media (max-width: 480px) {
    .category-grid { grid-template-columns: 1fr; }
    .calc-tabs { flex-direction: column; }
    .calc-tab { text-align: center; }
}
