@import './tokens.css';

/* ==========================================
   Base
   ========================================== */

body {
    background-color: var(--bg);
    color: var(--text);
    font-family: var(--font-family);
    font-size: var(--fs-base);
    margin: 0;
    padding: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
}

::selection {
    background: var(--link);
    color: var(--bg);
}

/* ==========================================
   Scrollbar (retro thin)
   ========================================== */

::-webkit-scrollbar {
    width: 14px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border: 2px solid var(--bg);
}

#ocean {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    overflow: hidden;
    color: var(--ocean-wave);
    font-size: 48px;
    line-height: 16px;
    white-space: pre;
    user-select: none;
    pointer-events: none;
}

.wave-row {
    width: 120%;
    display: block;
}

/* ==========================================
   UI Layer (header + footer overlay)
   ========================================== */

.ui-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    pointer-events: none;
    box-sizing: border-box;
    padding: 16px 20px;
}

.ui-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: auto;
}

.identity {
    display: flex;
    align-items: center;
    gap: 12px;
}

.identity h1 {
    margin: 0;
    font-size: var(--fs-lg);
    letter-spacing: 2px;
    text-transform: lowercase;
    color: var(--text-nav);
    font-weight: bold;
}

.identity h1 a {
    color: inherit;
    text-decoration: none;
    transition: color 0.15s;
}

.identity h1 a:hover {
    color: var(--text-primary);
    text-decoration: underline;
}

/* ==========================================
   Navigation
   ========================================== */

.ui-nav {
    display: flex;
    gap: 20px;
    align-items: center;
}

.ui-nav a {
    color: var(--text-nav);
    text-decoration: none;
    font-size: var(--fs-md);
    letter-spacing: 1px;
    transition: color 0.15s;
}

.ui-nav a:hover {
    color: var(--text-primary);
    text-decoration: underline;
}

.ui-nav a.active {
    color: var(--text-primary);
    text-decoration: underline;
}

/* Theme Toggle (footer) */
.theme-toggle {
    color: var(--text-footer);
    font-size: inherit;
    letter-spacing: inherit;
    transition: color 0.15s;
    user-select: none;
}

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

/* ==========================================
   Nav Dropdowns
   ========================================== */

.nav-dropdown {
    position: relative;
}

.nav-dropdown > a {
    cursor: pointer;
}

.nav-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    padding-top: 6px;
    background: transparent;
    min-width: 160px;
    z-index: 200;
}

.nav-dropdown-menu-inner {
    background: var(--bg-elevated);
    border: 2px outset var(--bevel-highlight);
    padding: 2px 0;
}

.nav-dropdown:hover .nav-dropdown-menu {
    display: block;
}

.nav-dropdown-menu-inner a {
    display: block;
    padding: 5px 14px;
    color: var(--text-nav);
    text-decoration: none;
    font-size: var(--fs-md);
    font-weight: normal;
    letter-spacing: 0;
    white-space: nowrap;
    transition: background-color 0.05s, color 0.05s;
}

.nav-dropdown-menu-inner a:hover {
    background: var(--link);
    color: var(--bg);
    text-decoration: none;
}

/* ==========================================
   Footer
   ========================================== */

.ui-footer {
    display: flex;
    justify-content: space-between;
    font-size: var(--fs-xs);
    letter-spacing: 1px;
    color: var(--text-footer);
    pointer-events: auto;
}

/* ==========================================
   Fish (home page)
   ========================================== */

.fish {
    white-space: pre;
    text-align: center;
    font-size: var(--fs-fish);
    color: var(--text-primary);
    z-index: 10;
    position: relative;
}

.fish-art {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1;
}

.fish-mask {
    background-color: var(--fish-mask);
}

#quote {
    margin-bottom: 12px;
    min-height: 3em;
    font-size: var(--fs-base);
    color: var(--text-content);
    line-height: 1.6;
}

/* ==========================================
   Content layer (blog + tools)
   ========================================== */

.content-layer {
    position: relative;
    z-index: 10;
    width: 100%;
    max-width: 640px;
    padding: 20px;
    box-sizing: border-box;
}

/* ==========================================
   Tool styles
   ========================================== */

.tool-section {
    padding: 0;
    margin-top: 0;
    pointer-events: auto;
}

.tool-section h2 {
    margin-top: 0;
    font-size: var(--fs-lg);
    letter-spacing: 1px;
    border-bottom: 1px dashed var(--border);
    padding-bottom: 10px;
    margin-bottom: 20px;
    color: var(--text-primary);
    font-weight: bold;
}

.tool-desc {
    font-size: var(--fs-sm);
    color: var(--text-muted);
    margin: -12px 0 20px 0;
}

.tool-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    margin-bottom: 16px;
}

.tool-row .input-group {
    margin-bottom: 0;
}

.tool-btn {
    background: var(--bg-elevated);
    border: 2px outset var(--bevel-highlight);
    color: var(--text);
    padding: 4px 12px;
    font-family: inherit;
    font-size: var(--fs-sm);
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: color 0.1s;
    white-space: nowrap;
}

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

.tool-btn:active {
    border-style: inset;
}

.tool-swap-row {
    display: flex;
    justify-content: center;
    margin: -4px 0 12px;
}

.tool-swap-row .tool-btn {
    font-size: var(--fs-lg);
    padding: 2px 12px;
    line-height: 1;
}

.input-group {
    margin-bottom: 16px;
}

.input-group label {
    display: block;
    font-size: var(--fs-xs);
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

input, select, textarea {
    background: var(--bg-input);
    border: 2px inset var(--bevel-shadow);
    color: var(--text);
    padding: 6px 8px;
    font-family: var(--font-family);
    font-size: var(--fs-base);
    width: 100%;
    box-sizing: border-box;
    transition: border-color 0.1s;
}

textarea {
    resize: vertical;
    min-height: 120px;
    font-family: var(--font-family);
}

input:focus, select:focus, textarea:focus {
    outline: 1px dotted var(--text-primary);
    outline-offset: -1px;
}

.result {
    margin-top: 16px;
    padding: 10px;
    background: var(--bg-result);
    border: 2px inset var(--bevel-shadow);
    font-size: var(--fs-base);
    word-break: break-all;
    color: var(--text-content);
}

/* ==========================================
   Blog styles
   ========================================== */

.post-list {
    list-style: none;
    padding: 0;
    pointer-events: auto;
}

.post-item {
    margin-bottom: 24px;
    padding-bottom: 12px;
    border-bottom: 1px dotted var(--border-subtle);
}

.post-date {
    font-size: var(--fs-xs);
    letter-spacing: 1px;
    color: var(--text-muted);
}

.post-title {
    font-size: var(--fs-lg);
    margin: 4px 0;
    font-weight: bold;
}

.post-title a {
    color: var(--link);
    text-decoration: underline;
    transition: color 0.15s;
}

.post-title a:hover {
    color: var(--link-hover);
}

.post-excerpt {
    color: var(--text-secondary);
    font-size: var(--fs-md);
    line-height: 1.5;
}

/* ==========================================
   Tools listing (index page)
   ========================================== */

.tool-list {
    list-style: none;
    padding: 0;
    pointer-events: auto;
}

.tool-item {
    margin-bottom: 24px;
    padding-bottom: 12px;
    border-bottom: 1px dotted var(--border-subtle);
}

.tool-item-title {
    font-size: var(--fs-lg);
    margin: 0 0 4px 0;
    font-weight: bold;
}

.tool-item-title a {
    color: var(--link);
    text-decoration: underline;
    transition: color 0.15s;
}

.tool-item-title a:hover {
    color: var(--link-hover);
}

.tool-item-desc {
    color: var(--text-secondary);
    font-size: var(--fs-md);
    line-height: 1.5;
}

/* ==========================================
   Blog & Tools Page: no-ocean layout
   ========================================== */

body.page-blog,
body.page-tools {
    background-color: var(--bg);
    justify-content: flex-start;
    align-items: stretch;
}

body.page-blog .ui-layer,
body.page-tools .ui-layer {
    position: relative;
    height: auto;
    padding: 16px 20px;
}

body.page-blog .ui-footer,
body.page-tools .ui-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 10px 20px;
    box-sizing: border-box;
    background: var(--bg);
}

/* Blog content area */
body.page-blog .content-layer {
    max-width: 640px;
    margin: 0 auto;
    padding: 20px 20px 80px;
}

/* Blog post article */
body.page-blog .blog-article {
    max-width: 640px;
    margin: 0 auto;
    padding: 20px 20px 80px;
}

body.page-blog .blog-article h1 {
    color: var(--text-primary);
    font-size: var(--fs-xl);
    margin-top: 8px;
    margin-bottom: 20px;
    font-weight: bold;
    line-height: 1.4;
}

body.page-blog .post-content {
    color: var(--text-content);
    font-size: var(--fs-base);
    line-height: 1.8;
}

body.page-blog .post-content p {
    margin-bottom: 1.2em;
}

body.page-blog .post-content h2 {
    font-size: var(--fs-lg);
    font-weight: bold;
    color: var(--text-primary);
    letter-spacing: 0.5px;
    margin-top: 2em;
    margin-bottom: 0.8em;
    border-bottom: 1px dashed var(--border);
    padding-bottom: 6px;
}

body.page-blog .post-content a {
    color: var(--link);
    text-decoration: underline;
    text-underline-offset: 2px;
}

body.page-blog .post-content a:hover {
    color: var(--link-hover);
}

/* Code blocks in blog */
body.page-blog .post-content pre {
    background: var(--bg-elevated);
    border: 2px inset var(--bevel-shadow);
    padding: 12px;
    overflow-x: auto;
    font-size: var(--fs-md);
    line-height: 1.6;
    margin: 1.5em 0;
}

body.page-blog .post-content code {
    font-family: var(--font-family);
    font-size: var(--fs-md);
}

body.page-blog .post-content p code,
body.page-blog .post-content li code {
    background: var(--bg-code);
    border: 1px solid var(--border);
    padding: 1px 4px;
    font-size: var(--fs-md);
}

/* Math blocks in blog */
body.page-blog .post-content .katex-display {
    margin: 1.5em 0;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 8px 0;
}

body.page-blog .post-content .katex {
    font-size: 1.1em;
}

/* Blog back link */
body.page-blog .back-link {
    color: var(--text-footer);
    text-decoration: underline;
    font-size: var(--fs-md);
    transition: color 0.15s;
}

body.page-blog .back-link:hover {
    color: var(--text-nav);
}

/* Tools page content area */
body.page-tools .content-layer {
    max-width: 640px;
    margin: 0 auto;
    padding: 20px 20px 80px;
}

/* Highlight.js overrides */
body.page-blog .hljs {
    background: transparent !important;
    padding: 0 !important;
}

/* ==========================================
   Cron explainer
   ========================================== */

.cron-examples {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    margin-bottom: 16px;
}

.cron-examples-label {
    font-size: var(--fs-xs);
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-right: 4px;
}

.cron-examples .tool-btn {
    font-size: var(--fs-xs);
    padding: 3px 8px;
}

.cron-format-label {
    font-size: var(--fs-xs);
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 4px;
    min-height: 1em;
}

.cron-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--fs-md);
}

.cron-table th {
    text-align: left;
    color: var(--text-secondary);
    font-weight: bold;
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 4px 8px;
    border-bottom: 1px solid var(--border);
}

.cron-table td {
    padding: 5px 8px;
    border-bottom: 1px dotted var(--border-subtle);
    color: var(--text-content);
}

.cron-table td:first-child {
    color: var(--text-secondary);
    white-space: nowrap;
}

.cron-table code {
    background: var(--bg-code);
    padding: 1px 4px;
    font-size: var(--fs-sm);
    color: var(--text);
}
