/* =========================================================================
   Journal -- styles.css
   Palette and primitives borrowed from hathapp/css/panel.css for visual
   continuity. Layout adapted for reading and writing prose, not dashboards.
   ========================================================================= */

*, *::before, *::after { box-sizing: border-box; }
body, h1, h2, h3, h4, h5, h6, p, ul, ol, li, figure, blockquote { margin: 0; padding: 0; }

:root {
    --bg:          #000000;
    --bg-surface:  #000000;
    --bg-elevated: #0a1118;
    --border:      #1e2d3d;
    --border-soft: rgba(30, 45, 61, 0.5);
    --text:        #dce4ec;
    --text-muted:  #6b839e;
    --text-dim:    #45596f;
    --accent:      #4A90D9;
    --accent-hover:#5DA0E8;
    --accent-dim:  rgba(74, 144, 217, 0.15);
    --red:         #ff4d4d;
    --green:       #2dd66b;
    --yellow:      #f5c518;

    --radius:    10px;
    --radius-sm: 6px;

    --font:   -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', system-ui, sans-serif;
    --mono:   'SF Mono', 'Menlo', 'Cascadia Code', monospace;
    --serif:  'Iowan Old Style', 'Charter', 'Georgia', serif;

    --read-width: 720px;
}

html { background: var(--bg); }
body {
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.55;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    min-height: 100dvh;
    color-scheme: dark;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

::selection { background: var(--accent-dim); color: var(--text); }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
.link { color: var(--text-muted); }
.link:hover { color: var(--text); }

/* =========================================================================
   Site Header
   ========================================================================= */
.site-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 24px;
    height: 52px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}
.site-header__brand {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: 0.18em;
    color: var(--accent);
    text-transform: uppercase;
    flex-shrink: 0;
}
.site-header__nav {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}
.site-header__link {
    padding: 8px 14px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-muted);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.site-header__link:hover {
    color: var(--text);
    border-color: var(--border);
}
.site-header__search input[type="search"] {
    padding: 8px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 16px;
    min-width: 220px;
    color-scheme: dark;
}
.site-header__search input[type="search"]:focus {
    outline: none;
    border-color: var(--accent);
}
.site-header__logout button {
    padding: 8px 14px;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.site-header__logout button:hover {
    color: var(--text);
    border-color: var(--text-muted);
}

/* =========================================================================
   Main Layout
   ========================================================================= */
.site-main {
    max-width: var(--read-width);
    margin: 0 auto;
    padding: 40px 24px 80px;
}

.page-title {
    font-size: 32px;
    font-weight: 800;
    letter-spacing: -0.01em;
    color: var(--text);
    margin-bottom: 24px;
}

.empty-state {
    padding: 24px 0;
    color: var(--text-muted);
    font-size: 16px;
}
.error {
    padding: 12px 14px;
    background: rgba(255, 77, 77, 0.08);
    border: 1px solid rgba(255, 77, 77, 0.4);
    border-radius: var(--radius-sm);
    color: var(--red);
    margin-bottom: 16px;
    font-size: 16px;
}

/* =========================================================================
   Buttons + Forms
   ========================================================================= */
button.primary, .primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    background: var(--accent);
    color: #000;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    transition: background 0.15s, transform 0.1s;
}
button.primary:hover, .primary:hover { background: var(--accent-hover); }
button.primary:active { transform: scale(0.98); }
button.primary:disabled { opacity: 0.4; cursor: default; transform: none; }

input[type="text"], input[type="password"], input[type="search"], textarea {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 16px;
    color-scheme: dark;
    font-family: var(--font);
}
input[type="text"]:focus, input[type="password"]:focus,
input[type="search"]:focus, textarea:focus {
    outline: none; border-color: var(--accent);
}
input::placeholder, textarea::placeholder { color: var(--text-dim); }

.field { display: block; margin-bottom: 16px; }
.field__label {
    display: block;
    font-size: 14px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 8px;
}
.field input {
    width: 100%;
    padding: 12px 14px;
}

/* =========================================================================
   Login
   ========================================================================= */
.login-card {
    max-width: 360px;
    margin: 80px auto 0;
    padding: 32px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.login-card .page-title {
    font-size: 24px;
    margin-bottom: 24px;
    text-align: center;
}
.login-form .primary { width: 100%; }

/* =========================================================================
   Entry List
   ========================================================================= */
.entry-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0;
}
.entry-list__item {
    padding: 18px 0;
    border-bottom: 1px solid var(--border-soft);
}
.entry-list__item:first-child { padding-top: 0; }
.entry-list__item:last-child { border-bottom: none; }

.entry-list__link {
    display: flex;
    align-items: baseline;
    gap: 16px;
    color: var(--text);
}
.entry-list__link:hover .entry-list__title { color: var(--accent); }

.entry-list__date {
    font-family: var(--mono);
    font-size: 14px;
    color: var(--text-muted);
    flex-shrink: 0;
    letter-spacing: 0.04em;
}
.entry-list__title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    transition: color 0.15s;
}
.entry-list__snippet {
    margin-top: 6px;
    margin-left: 116px;
    color: var(--text-muted);
    font-size: 16px;
    line-height: 1.55;
}
@media (max-width: 600px) {
    .entry-list__link { flex-direction: column; gap: 4px; }
    .entry-list__snippet { margin-left: 0; }
}

/* =========================================================================
   Entry (read view)
   ========================================================================= */
.entry__header {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 32px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}
.entry__back {
    align-self: flex-start;
    font-size: 14px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.entry__back:hover { color: var(--accent); }
.entry__title {
    font-size: 28px;
    font-weight: 800;
    color: var(--text);
    line-height: 1.2;
}
.entry__meta {
    display: flex;
    align-items: center;
    gap: 16px;
    font-family: var(--mono);
    font-size: 14px;
    color: var(--text-muted);
}
.entry__edit {
    margin-left: auto;
    font-family: var(--font);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.entry__body {
    font-family: var(--serif);
    font-size: 18px;
    line-height: 1.7;
    color: var(--text);
}
.entry__body h1, .entry__body h2, .entry__body h3,
.entry__body h4, .entry__body h5, .entry__body h6 {
    font-family: var(--font);
    font-weight: 700;
    margin-top: 1.6em;
    margin-bottom: 0.6em;
    color: var(--text);
}
.entry__body h1 { font-size: 26px; }
.entry__body h2 { font-size: 22px; }
.entry__body h3 { font-size: 19px; }
.entry__body h4, .entry__body h5, .entry__body h6 { font-size: 17px; }
.entry__body p { margin-bottom: 1.1em; }
.entry__body ul, .entry__body ol { margin: 0 0 1.1em 1.4em; }
.entry__body li { margin-bottom: 0.4em; }
.entry__body blockquote {
    margin: 1.2em 0;
    padding: 4px 0 4px 18px;
    border-left: 3px solid var(--accent);
    color: var(--text-muted);
    font-style: italic;
}
.entry__body code {
    font-family: var(--mono);
    font-size: 0.92em;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 6px;
}
.entry__body pre {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    margin: 1.2em 0;
    overflow-x: auto;
    font-family: var(--mono);
    font-size: 14px;
    line-height: 1.5;
}
.entry__body pre code { background: none; border: none; padding: 0; }
.entry__body hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 2em 0;
}
.entry__body a { color: var(--accent); text-decoration: underline; }
.entry__body a:hover { color: var(--accent-hover); }

/* =========================================================================
   Editor
   ========================================================================= */
.editor-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.editor-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}
.editor-header .page-title {
    margin-bottom: 0;
    font-size: 22px;
    font-family: var(--mono);
    letter-spacing: 0;
    font-weight: 700;
}
.editor-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
}
.editor {
    width: 100%;
    min-height: 60vh;
    padding: 20px 22px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--mono);
    font-size: 16px;
    line-height: 1.6;
    resize: vertical;
    color-scheme: dark;
}
.editor:focus { outline: none; border-color: var(--accent); }

/* =========================================================================
   Search
   ========================================================================= */
.search-form {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
}
.search-form input[type="search"] {
    flex: 1;
    padding: 12px 14px;
    font-size: 16px;
}
.search-meta {
    color: var(--text-muted);
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 12px;
}
