/* ============================================================
   Simple Study Tools - Main Stylesheet
   ============================================================ */

:root {
    --color-primary: #0a5c9c;
    --color-primary-dark: #074574;
    --color-accent: #14b8a6;
    --color-text: #1f2933;
    --color-muted: #5b6770;
    --color-border: #e3e8ee;
    --color-bg: #ffffff;
    --color-bg-alt: #f6f9fc;
    --color-bg-card: #ffffff;
    --color-danger: #dc2626;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 8px 24px rgba(15, 23, 42, 0.10);
    --max-width: 1180px;
    --header-h: 64px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu,
        Cantarell, "Helvetica Neue", Arial, sans-serif;
    --mono: "SFMono-Regular", Menlo, Monaco, Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--font);
    color: var(--color-text);
    background: var(--color-bg);
    line-height: 1.6;
    font-size: 16px;
}
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { max-width: 100%; display: block; }
h1, h2, h3, h4 { line-height: 1.3; font-weight: 700; color: var(--color-text); }
h1 { font-size: clamp(1.7rem, 3vw, 2.4rem); margin-bottom: 0.5em; }
h2 { font-size: clamp(1.3rem, 2.2vw, 1.7rem); margin: 1.5em 0 0.6em; }
h3 { font-size: 1.15rem; margin-bottom: 0.4em; }
p { margin-bottom: 1em; }
ul, ol { margin-bottom: 1em; padding-left: 1.4em; }
code { font-family: var(--mono); background: var(--color-bg-alt); padding: 0.1em 0.35em; border-radius: 4px; font-size: 0.92em; }

.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 20px;
    width: 100%;
}
.narrow { max-width: 760px; }
.center { text-align: center; }
.section { padding: 36px 0; }
.btn {
    display: inline-block;
    background: var(--color-primary);
    color: #fff;
    padding: 10px 20px;
    border-radius: var(--radius);
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: background 0.15s ease;
}
.btn:hover { background: var(--color-primary-dark); text-decoration: none; }

/* ===== Header ===== */
.site-header {
    background: #fff;
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}
.header-inner {
    display: flex;
    align-items: center;
    gap: 18px;
    height: var(--header-h);
}
.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--color-text);
    flex-shrink: 0;
}
.logo:hover { text-decoration: none; }
.logo-mark {
    background: var(--color-primary);
    color: #fff;
    width: 34px; height: 34px;
    display: grid; place-items: center;
    border-radius: 8px;
    font-size: 1.2rem;
    font-weight: 700;
}
.main-nav {
    display: flex;
    gap: 4px;
    flex: 1;
}
.main-nav a {
    color: var(--color-text);
    padding: 8px 12px;
    border-radius: 6px;
    font-weight: 500;
    font-size: 0.95rem;
}
.main-nav a:hover {
    background: var(--color-bg-alt);
    text-decoration: none;
    color: var(--color-primary);
}
.header-search {
    display: flex;
    flex-shrink: 0;
}
.header-search input {
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: 6px 0 0 6px;
    font-size: 0.9rem;
    width: 180px;
    border-right: none;
}
.header-search button {
    background: var(--color-primary);
    color: #fff;
    border: none;
    padding: 8px 14px;
    border-radius: 0 6px 6px 0;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
}
.nav-toggle {
    display: none;
    background: none;
    border: none;
    flex-direction: column;
    gap: 4px;
    cursor: pointer;
    padding: 6px;
}
.nav-toggle span {
    width: 22px;
    height: 2px;
    background: var(--color-text);
    transition: 0.2s;
}

/* ===== Hero ===== */
.hero {
    background: linear-gradient(135deg, #f0f9ff, #e0f2fe);
    padding: 50px 0 40px;
    text-align: center;
}
.hero h1 { margin-bottom: 0.3em; }
.hero-subtitle {
    font-size: 1.1rem;
    color: var(--color-muted);
    max-width: 640px;
    margin: 0 auto 1.6em;
}
.hero-search {
    display: flex;
    max-width: 580px;
    margin: 0 auto 24px;
    box-shadow: var(--shadow);
    border-radius: var(--radius);
    overflow: hidden;
}
.hero-search input {
    flex: 1;
    padding: 14px 18px;
    border: 1px solid var(--color-border);
    font-size: 1rem;
    border-right: none;
}
.hero-search button {
    padding: 14px 26px;
    background: var(--color-primary);
    color: #fff;
    border: none;
    font-weight: 600;
    cursor: pointer;
    font-size: 1rem;
}
.hero-search button:hover { background: var(--color-primary-dark); }

/* ===== Category Grid ===== */
.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
    margin-top: 12px;
}
.category-card {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 22px;
    display: block;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
    color: var(--color-text);
}
.category-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: var(--color-primary);
    text-decoration: none;
}
.category-icon {
    display: inline-grid;
    place-items: center;
    width: 46px; height: 46px;
    background: var(--color-bg-alt);
    color: var(--color-primary);
    border-radius: 10px;
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 12px;
}
.category-count { font-size: 0.85rem; color: var(--color-muted); }

/* ===== Tool Grid ===== */
.tool-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
    margin-top: 12px;
}
.tool-grid-large { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.tool-card {
    position: relative;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 18px;
    display: block;
    color: var(--color-text);
    transition: all 0.15s ease;
}
.tool-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: var(--color-primary);
    text-decoration: none;
}
.tool-card h3 { color: var(--color-primary); margin-bottom: 6px; font-size: 1.05rem; }
.tool-card p { font-size: 0.9rem; color: var(--color-muted); margin-bottom: 8px; line-height: 1.45; }
.tool-link { font-size: 0.85rem; color: var(--color-accent); font-weight: 600; }
.badge-new {
    position: absolute;
    top: 10px; right: 10px;
    background: var(--color-accent);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ===== Two-column layout ===== */
.tool-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 32px;
    align-items: start;
}
.sidebar { 
    position: sticky; 
    top: calc(var(--header-h) + 16px); 
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.sidebar-widget {
    background: var(--color-bg-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 18px;
}
.sidebar-widget h3 { font-size: 1rem; margin-bottom: 10px; }
.quick-links { list-style: none; padding-left: 0; }
.quick-links li { padding: 5px 0; border-bottom: 1px solid var(--color-border); font-size: 0.9rem; }
.quick-links li:last-child { border-bottom: none; }

/* ===== Tool Page Layout ===== */
.breadcrumbs { font-size: 0.85rem; color: var(--color-muted); margin-bottom: 14px; }
.breadcrumbs a { color: var(--color-muted); }
.breadcrumbs a:hover { color: var(--color-primary); }
.tool-intro { color: var(--color-muted); font-size: 1.05rem; margin-bottom: 20px; }

.tool-widget {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
}
.tool-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 16px;
}
.tool-row label {
    display: block;
    font-size: 0.88rem;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--color-text);
}
.tool-row input, .tool-row select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 1rem;
    font-family: inherit;
    background: #fff;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.tool-row input:focus, .tool-row select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(10, 92, 156, 0.12);
}
.tool-result {
    background: var(--color-bg-alt);
    border-left: 4px solid var(--color-accent);
    border-radius: 6px;
    padding: 14px 18px;
    margin-top: 8px;
    font-size: 1rem;
}
.tool-result strong { color: var(--color-primary); font-size: 1.1rem; }
.tool-result .result-line { margin: 4px 0; }

/* Hide useless calculate buttons - tools auto-calculate on input */
.btn-calc { display: none !important; }

.error { color: var(--color-danger); font-size: 0.9rem; }

/* ===== Tool sections ===== */
.tool-section {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 22px;
    margin-bottom: 20px;
}
.tool-section h2 { margin-top: 0; }
.formula-list { list-style: none; padding-left: 0; }
.formula-list li {
    padding: 10px 14px;
    background: var(--color-bg-alt);
    border-radius: 6px;
    margin-bottom: 8px;
    font-family: var(--mono);
    font-size: 0.92rem;
}
.faq-item {
    border: 1px solid var(--color-border);
    border-radius: 6px;
    margin-bottom: 8px;
    overflow: hidden;
}
.faq-item summary {
    padding: 14px 16px;
    font-weight: 600;
    cursor: pointer;
    list-style: none;
    position: relative;
    padding-right: 40px;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
    content: "+";
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.3rem;
    color: var(--color-primary);
}
.faq-item[open] summary::after { content: "−"; }
.faq-item summary:hover { background: var(--color-bg-alt); }
.faq-item p { padding: 0 16px 14px; margin: 0; color: var(--color-muted); }

/* ===== SEO text ===== */
.seo-text {
    background: var(--color-bg-alt);
    border-radius: var(--radius);
    padding: 28px;
    margin-top: 20px;
    color: var(--color-muted);
}
.seo-text h2 { color: var(--color-text); }

/* ===== Ads ===== */
.ad-placeholder {
    background: repeating-linear-gradient(45deg, #f1f5f9, #f1f5f9 10px, #e2e8f0 10px, #e2e8f0 20px);
    border: 1px dashed #cbd5e1;
    color: #64748b;
    display: grid;
    place-items: center;
    min-height: 90px;
    margin: 20px 0;
    border-radius: var(--radius);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.ad-placeholder.ad-vertical { min-height: 600px; }
.ad-placeholder.ad-horizontal { min-height: 90px; max-width: 970px; margin-left: auto; margin-right: auto; }
.ad-placeholder.ad-fluid { min-height: 120px; }
.ad-unit { margin: 20px 0; overflow: hidden; }

/* ===== Footer ===== */
.site-footer {
    background: #0f172a;
    color: #cbd5e1;
    padding: 50px 0 0;
    margin-top: 50px;
}
.footer-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 32px;
    padding-bottom: 32px;
}
.footer-col h3 { color: #fff; margin-bottom: 12px; font-size: 1.15rem; }
.footer-col h4 { color: #fff; margin-bottom: 12px; font-size: 1rem; }
.footer-col p { font-size: 0.9rem; color: #94a3b8; }
.footer-col ul { list-style: none; padding-left: 0; }
.footer-col li { margin-bottom: 8px; }
.footer-col a { color: #cbd5e1; font-size: 0.9rem; }
.footer-col a:hover { color: #fff; }
.footer-bottom {
    border-top: 1px solid #1e293b;
    padding: 18px 0;
    font-size: 0.85rem;
    color: #64748b;
    text-align: center;
}

/* ===== Responsive ===== */
@media (max-width: 960px) {
    .tool-layout { grid-template-columns: 1fr; }
    .sidebar { position: static; }
    .footer-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 720px) {
    .main-nav, .header-search { display: none; }
    .nav-toggle { display: flex; }
    .main-nav.open {
        display: flex;
        flex-direction: column;
        position: absolute;
        top: var(--header-h);
        left: 0; right: 0;
        background: #fff;
        padding: 14px 20px;
        border-bottom: 1px solid var(--color-border);
        box-shadow: var(--shadow);
    }
    .main-nav.open a { padding: 10px 0; }
    .hero { padding: 32px 0; }
    .footer-grid { grid-template-columns: 1fr; }
    .section { padding: 24px 0; }
    .tool-widget, .tool-section { padding: 16px; }
    .tool-row { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
    .hero-search { flex-direction: column; border-radius: var(--radius); }
    .hero-search input { border: 1px solid var(--color-border); border-radius: 6px; margin-bottom: 8px; }
    .hero-search button { border-radius: 6px; padding: 12px; }
    .tool-grid { grid-template-columns: 1fr; }
}