/* ============================================
   Phasm — style.css
   ============================================ */

/* --- Reset & Variables --- */

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --green: #4A7C59;
    --green-light: #A8D5BA;
    --green-dark: #2E4D3A;
    --yellow: #D4A843;
    --bg: #1A1A1A;
    --surface: #2A2A2A;
    --text: #F5F9F6;
    --text-muted: #9CA89E;
    --outline: #4A4A4A;
    --radius: 12px;
    --radius-sm: 8px;
    --nav-height: 64px;
}

@media (prefers-color-scheme: light) {
    :root {
        --bg: #F5F9F6;
        --surface: #E8F0EA;
        --text: #1A1A1A;
        --text-muted: #5A6B5E;
        --outline: #BCC8BF;
    }
}

/* --- Base --- */

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
}

a {
    color: var(--green-light);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--yellow);
}

@media (prefers-color-scheme: light) {
    a { color: var(--green); }
    a:hover { color: var(--green-dark); }
}

img {
    max-width: 100%;
    height: auto;
}

/* --- Navigation --- */

.nav {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(26, 26, 26, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--outline);
    height: var(--nav-height);
}

@media (prefers-color-scheme: light) {
    .nav {
        background: rgba(245, 249, 246, 0.92);
    }
}

.nav-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1.5rem;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-logo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text);
    text-decoration: none;
}

.nav-logo img {
    border-radius: 8px;
}

.nav-logo:hover {
    color: var(--text);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.nav-links a {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.2s;
}

.nav-links a:hover {
    color: var(--text);
}

.nav-cta {
    background: var(--green);
    color: #fff !important;
    padding: 0.45rem 1.1rem;
    border-radius: 100px;
    font-size: 0.85rem !important;
    font-weight: 600 !important;
    transition: background 0.2s, transform 0.1s !important;
}

.nav-cta:hover {
    background: var(--green-dark);
    color: #fff !important;
    transform: translateY(-1px);
}

/* Mobile nav toggle */
.nav-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    flex-direction: column;
    gap: 5px;
}

.nav-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
    transition: transform 0.2s, opacity 0.2s;
}

.nav-toggle[aria-expanded="true"] span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.nav-toggle[aria-expanded="true"] span:nth-child(2) {
    opacity: 0;
}

.nav-toggle[aria-expanded="true"] span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

@media (max-width: 680px) {
    .nav-toggle {
        display: flex;
    }

    .nav-links {
        display: none;
        position: absolute;
        top: var(--nav-height);
        left: 0;
        right: 0;
        background: var(--surface);
        border-bottom: 1px solid var(--outline);
        flex-direction: column;
        padding: 1rem 1.5rem;
        gap: 0;
    }

    .nav-links.open {
        display: flex;
    }

    .nav-links a {
        padding: 0.75rem 0;
        border-bottom: 1px solid var(--outline);
        width: 100%;
    }

    .nav-links a:last-child {
        border-bottom: none;
        margin-top: 0.5rem;
        text-align: center;
    }
}

/* --- Section Layout --- */

.section {
    max-width: 1100px;
    margin: 0 auto;
    padding: 4rem 1.5rem;
}

.section-narrow {
    max-width: 720px;
}

.section-title {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 0.5rem;
}

.section-subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
    margin-bottom: 2.5rem;
    max-width: 540px;
}

.text-center {
    text-align: center;
}

.text-center .section-subtitle {
    margin-left: auto;
    margin-right: auto;
}

/* --- Hero --- */

.hero {
    text-align: center;
    padding: 5rem 1.5rem 3rem;
    max-width: 720px;
    margin: 0 auto;
}

.hero-logo {
    width: 120px;
    height: 120px;
    border-radius: 28px;
    margin-bottom: 2rem;
    filter: drop-shadow(0 8px 24px rgba(74, 124, 89, 0.3));
}

.hero h1 {
    font-size: 2.75rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.15;
    margin-bottom: 1rem;
}

.hero .tagline {
    font-size: 1.2rem;
    color: var(--text-muted);
    max-width: 500px;
    margin: 0 auto 2rem;
}

.hero-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.7rem 1.5rem;
    border-radius: 100px;
    font-size: 0.95rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    text-decoration: none;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn-primary {
    background: var(--green);
    color: #fff;
}

.btn-primary:hover {
    background: var(--green-dark);
    color: #fff;
}

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--outline);
}

.btn-secondary:hover {
    border-color: var(--green);
}

/* --- Tool UI --- */

.tool-section {
    max-width: 680px;
    margin: 0 auto;
    padding: 0 1.5rem 4rem;
}

.tool-card {
    background: var(--surface);
    border: 1px solid var(--outline);
    border-radius: var(--radius);
    overflow: hidden;
}

.tool-tabs {
    display: flex;
    border-bottom: 1px solid var(--outline);
}

.tool-tab {
    flex: 1;
    padding: 0.9rem;
    text-align: center;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    background: none;
    border: none;
    color: var(--text-muted);
    transition: color 0.2s, box-shadow 0.2s;
    position: relative;
}

.tool-tab:hover {
    color: var(--text);
}

.tool-tab.active {
    color: var(--green-light);
    box-shadow: inset 0 -2px 0 var(--green);
}

@media (prefers-color-scheme: light) {
    .tool-tab.active {
        color: var(--green-dark);
    }
}

.tool-panel {
    display: none;
    padding: 1.5rem;
}

.tool-panel.active {
    display: block;
}

/* Mode selector */
.mode-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.mode-buttons {
    display: flex;
    flex: 1;
    gap: 0;
    border: 1px solid var(--outline);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.mode-btn {
    flex: 1;
    padding: 0.6rem 1rem;
    background: var(--bg);
    color: var(--text-muted);
    border: none;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}

.mode-btn + .mode-btn {
    border-left: 1px solid var(--outline);
}

.mode-btn:hover {
    color: var(--text);
}

.mode-btn.active {
    background: var(--green);
    color: #fff;
    border-color: var(--green);
}

.mode-btn-icon {
    font-size: 1rem;
}

.mode-info-btn {
    background: none;
    border: none;
    color: var(--green-light);
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    min-height: 40px;
    transition: color 0.2s;
}

.mode-info-btn:hover {
    color: var(--yellow);
}

@media (prefers-color-scheme: light) {
    .mode-info-btn {
        color: var(--green-dark);
    }
    .mode-info-btn:hover {
        color: var(--green);
    }
}

.mode-description {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.4rem;
    transition: opacity 0.2s;
}

/* Mode info dialog */
.mode-dialog-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 300;
    padding: 1.5rem;
}

.mode-dialog-overlay[hidden] {
    display: none;
}

.mode-dialog {
    background: var(--surface);
    border: 1px solid var(--outline);
    border-radius: var(--radius);
    padding: 1.5rem;
    max-width: 400px;
    width: 100%;
}

.mode-dialog h3 {
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
}

.mode-dialog p {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 1.25rem;
}

.mode-dialog-close {
    width: 100%;
    justify-content: center;
}

.tool-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* Drop zone */
.drop-zone {
    border: 2px dashed var(--outline);
    border-radius: var(--radius-sm);
    padding: 2.5rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    position: relative;
}

.drop-zone:hover,
.drop-zone.dragover {
    border-color: var(--green);
    background: rgba(74, 124, 89, 0.08);
}

.drop-zone.has-file {
    border-color: var(--green);
    border-style: solid;
}

.drop-zone.error {
    border-color: #c0392b;
    background: rgba(192, 57, 43, 0.08);
}

.drop-zone-label {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.drop-zone.has-file .drop-zone-label {
    color: var(--green-light);
    font-weight: 500;
}

@media (prefers-color-scheme: light) {
    .drop-zone.has-file .drop-zone-label {
        color: var(--green-dark);
    }
}

.drop-zone-icon {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    display: block;
}

.drop-zone-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

/* Form fields */
.tool-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}

.tool-input,
.tool-textarea {
    width: 100%;
    padding: 0.7rem 1rem;
    background: var(--bg);
    border: 1px solid var(--outline);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: inherit;
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

.tool-input:focus,
.tool-textarea:focus {
    outline: none;
    border-color: var(--green);
}

.tool-textarea {
    min-height: 100px;
    resize: vertical;
}

.tool-passphrase {
    font-family: monospace;
}

.tool-submit {
    align-self: flex-start;
}

/* Capacity bar (placeholder) */
.capacity-bar {
    background: var(--bg);
    border-radius: 100px;
    height: 6px;
    overflow: hidden;
    margin-top: 0.25rem;
}

.capacity-fill {
    height: 100%;
    width: 0%;
    background: var(--green);
    border-radius: 100px;
    transition: width 0.5s ease;
}

.capacity-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.3rem;
}

/* --- Features --- */

.features-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem;
}

.feature-card {
    background: var(--surface);
    border: 1px solid var(--outline);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-align: left;
}

.feature-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    background: var(--green-dark);
    margin-bottom: 1rem;
}

@media (prefers-color-scheme: light) {
    .feature-icon {
        background: var(--green-light);
    }
}

.feature-card h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
    color: var(--green-light);
}

@media (prefers-color-scheme: light) {
    .feature-card h3 {
        color: var(--green-dark);
    }
}

.feature-card p {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.55;
}

@media (max-width: 680px) {
    .features-grid {
        grid-template-columns: 1fr;
    }
}

/* --- App Promo --- */

.app-promo {
    text-align: center;
    background: var(--surface);
    border-top: 1px solid var(--outline);
    border-bottom: 1px solid var(--outline);
}

.app-badges {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.badge-link {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    background: var(--bg);
    border: 1px solid var(--outline);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1.25rem;
    color: var(--text);
    font-weight: 600;
    font-size: 0.9rem;
    transition: border-color 0.2s, transform 0.1s;
}

.badge-link:hover {
    border-color: var(--green);
    color: var(--text);
    transform: translateY(-1px);
}

.badge-link svg {
    flex-shrink: 0;
}

.badge-label-small {
    font-size: 0.7rem;
    font-weight: 400;
    color: var(--text-muted);
    display: block;
    line-height: 1;
}

.badge-label-big {
    font-size: 0.95rem;
    line-height: 1.2;
}

/* --- Blog --- */

.blog-list {
    display: grid;
    gap: 1.5rem;
}

.blog-card {
    background: var(--surface);
    border: 1px solid var(--outline);
    border-radius: var(--radius);
    padding: 1.5rem;
    transition: border-color 0.2s;
}

.blog-card:hover {
    border-color: var(--green);
}

.blog-card-date {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}

.blog-card h2 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.blog-card h2 a {
    color: var(--text);
}

.blog-card h2 a:hover {
    color: var(--green-light);
}

@media (prefers-color-scheme: light) {
    .blog-card h2 a:hover {
        color: var(--green);
    }
}

.blog-card p {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.55;
    margin-bottom: 0.75rem;
}

.read-more {
    font-size: 0.85rem;
    font-weight: 600;
}

/* --- Blog Post / Article --- */

.article {
    max-width: 720px;
    margin: 0 auto;
    padding: 3rem 1.5rem 4rem;
}

.article-header {
    margin-bottom: 2.5rem;
}

.article-date {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.article h1 {
    font-size: 2.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.article-body h2 {
    font-size: 1.4rem;
    font-weight: 600;
    margin: 2rem 0 0.75rem;
}

.article-body h3 {
    font-size: 1.15rem;
    font-weight: 600;
    margin: 1.5rem 0 0.5rem;
}

.article-body p {
    margin-bottom: 1rem;
    line-height: 1.7;
}

.article-body ul,
.article-body ol {
    margin: 0.5rem 0 1rem 1.5rem;
    line-height: 1.7;
}

.article-body li {
    margin-bottom: 0.3rem;
}

.article-body code {
    background: var(--surface);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.9em;
}

.article-body blockquote {
    border-left: 3px solid var(--green);
    padding: 0.5rem 1rem;
    margin: 1rem 0;
    color: var(--text-muted);
    background: var(--surface);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* Article CTA box */
.article-cta {
    background: var(--surface);
    border: 1px solid var(--outline);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-top: 3rem;
    text-align: center;
}

.article-cta h3 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.article-cta p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

/* --- Press Kit --- */

.press-section {
    margin-bottom: 3rem;
}

.press-section h2 {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--outline);
}

.press-section p {
    line-height: 1.7;
    margin-bottom: 0.75rem;
}

.press-assets {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
}

.press-asset {
    background: var(--surface);
    border: 1px solid var(--outline);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-align: center;
    transition: border-color 0.2s;
}

.press-asset:hover {
    border-color: var(--green);
}

.press-asset img {
    max-height: 80px;
    margin-bottom: 0.75rem;
}

.press-asset .asset-name {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.press-asset .asset-format {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* --- 404 --- */

.page-404 {
    text-align: center;
    padding: 6rem 1.5rem;
}

.page-404 h1 {
    font-size: 5rem;
    font-weight: 700;
    color: var(--green);
    margin-bottom: 0.5rem;
}

.page-404 p {
    color: var(--text-muted);
    font-size: 1.1rem;
    margin-bottom: 2rem;
}

/* --- Footer --- */

.site-footer {
    border-top: 1px solid var(--outline);
    padding: 2rem 1.5rem;
    margin-top: auto;
}

.footer-inner {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.footer-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 0.9rem;
}

.footer-brand img {
    border-radius: 6px;
}

.footer-links {
    display: flex;
    gap: 1.5rem;
}

.footer-links a {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
}

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

.footer-copy {
    font-size: 0.75rem;
    color: var(--text-muted);
    width: 100%;
    text-align: center;
    margin-top: 0.5rem;
}

@media (max-width: 680px) {
    .footer-inner {
        flex-direction: column;
        text-align: center;
    }
}

/* --- Toast --- */

.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--green-dark);
    color: #fff;
    padding: 0.8rem 1.5rem;
    border-radius: 100px;
    font-size: 0.9rem;
    font-weight: 500;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    z-index: 200;
    pointer-events: none;
    white-space: nowrap;
    max-width: 90vw;
}

.toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* --- Processing & Result States --- */

.tool-submit:disabled {
    opacity: 0.6;
    cursor: wait;
}

.decode-result {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.decode-result textarea {
    background: var(--bg);
    border: 1px solid var(--green);
    min-height: 80px;
}

/* --- Responsive --- */

@media (max-width: 480px) {
    .hero h1 {
        font-size: 2rem;
    }

    .hero .tagline {
        font-size: 1.05rem;
    }

    .section-title {
        font-size: 1.6rem;
    }

    .article h1 {
        font-size: 1.75rem;
    }

    .section {
        padding: 2.5rem 1rem;
    }
}
