/* ==========================================================================
   ASETMJ manuscript validator
   Design system transcribed from docs/ASETMJ_design_audit.docx (Appendix A).

   Where the audit's section 12 flags a defect in the live site, this file
   follows the recommendation rather than the current behaviour. Each such
   deviation is marked "audit 12.x".
   ========================================================================== */

:root {
    /* --- Colour tokens (audit, Appendix A) --- */
    --color-text: #404040;
    --color-text-meta: #6B7280;      /* audit 12.1#2: was #AAA, 2.12:1 on grey */
    --color-link: #1F4E8C;           /* audit 12.1#1: was #999, 2.85:1 on white */
    --color-link-hover: #143A69;
    --color-surface: #FFFFFF;
    --color-surface-alt: #F5F5F5;
    --color-divider: #F6F6F6;
    --color-divider-strong: #EEEEEE;
    --color-field-border: #DDDDDD;
    --color-sidebar: #383F49;
    --color-sidebar-deep: #30353C;
    --color-on-dark: #BABFC5;
    --color-on-dark-active: #FFFFFF;
    --color-accent: #2B618E;

    /* Status colours. The interface is otherwise achromatic, so these are the
       only chromatic UI elements — kept dark enough to pass WCAG AA on their
       tinted plaques. Bronze is lifted from the journal's own cover art. */
    --color-ok: #1F6B3A;
    --color-ok-tint: #F1F6F2;
    --color-warn: #886038;           /* --brand-bronze */
    --color-warn-tint: #F9F5EE;
    --color-danger: #A32B2B;
    --color-danger-tint: #FBF1F1;

    /* --- Type tokens --- */
    --font-body: Arial, "Source Sans Pro", "Helvetica Neue", Helvetica, sans-serif;
    --font-heading: Arial, "Roboto Condensed", "Helvetica Neue", Helvetica, sans-serif;
    --font-mono: "Courier 10 Pitch", Courier, monospace;

    --size-h1: 32px;                 /* audit 12.1#3: visible H1, not 80px */
    --size-h2: 24px;
    --size-h3: 30px;
    --size-h4: 20px;
    --size-body: 18px;               /* audit 12.2#6: not the inline 17px */
    --size-nav: 18px;
    --size-button: 16px;
    --size-meta: 14px;

    /* --- Everything else --- */
    --radius-sm: 2px;
    --radius-tab: 6px 6px 0 0;
    --transition: .07s ease-in;
    --sidebar-width: clamp(250px, 20%, 330px);
    --content-gap: 60px;
    --content-max: 1000px;
    --measure: 68ch;                 /* audit 12.2#8: was ~90-100 characters */
    --toggle-bar-height: 44px;
}

/* --------------------------------------------------------------- 1.0 Reset */

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

body {
    margin: 0;
    background: var(--color-surface);
    color: var(--color-text);
    font-family: var(--font-body);
    font-size: var(--size-body);
    line-height: 1.5;
}

h1, h2, h3, h4 {
    font-family: var(--font-heading);
    font-weight: 400;
    line-height: 1.2;
    margin: 0 0 .6em;
}

h1 { font-size: var(--size-h1); }
h2 { font-size: var(--size-h2); }
h3 { font-size: var(--size-h3); }
h4 { font-size: var(--size-h4); }

p { margin: 0 0 1em; }

a {
    color: var(--color-link);
    text-decoration: underline;      /* audit 12.1#1: links must be identifiable */
    transition: color var(--transition);
}
a:hover { color: var(--color-link-hover); }

code, kbd {
    font-family: var(--font-mono);
    font-size: .92em;
    background: var(--color-surface-alt);
    padding: 1px 4px;
}

:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

.meta {
    font-size: var(--size-meta);
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--color-text-meta);
}

/* LaTeX control sequences are case-sensitive — never let the meta
   uppercasing turn \author into \AUTHOR. */
.meta code { text-transform: none; letter-spacing: 0; }

.visually-hidden {
    position: absolute;
    width: 1px; height: 1px;
    margin: -1px; padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* ------------------------------------------------------- 2.0 Toggle bar */

.toggle-bar {
    position: fixed;
    top: 0; left: 0;
    width: 100%;
    height: var(--toggle-bar-height);
    padding: 8px 30px 0;
    background: var(--color-sidebar-deep);
    display: flex;
    gap: 4px;
    z-index: 200;
}

.toggle-bar button {
    display: flex;
    align-items: center;
    gap: 8px;
    border: 0;
    background: none;
    color: #878D94;
    font-family: var(--font-heading);
    font-size: 12px;
    letter-spacing: 1px;
    text-transform: uppercase;
    padding: 0 14px;
    height: 36px;
    border-radius: var(--radius-tab);
    cursor: pointer;
    transition: color var(--transition), background var(--transition);
}

.toggle-bar button:hover { color: var(--color-on-dark-active); }

.toggle-bar button[aria-expanded="true"] {
    color: var(--color-on-dark-active);
    background: var(--color-sidebar);
}

.toggle-bar svg { width: 15px; height: 15px; fill: currentColor; flex: none; }

/* Session strip — pushed to the far end of the bar, away from the tabs. */
.toggle-bar .session {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
    height: 36px;
    font-size: 12px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: #878D94;
}

.toggle-bar .session form { margin: 0; }

/* ---------------------------------------------------------- 3.0 Sidebar */

.site-header {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-width);
    height: 100%;
    padding: calc(var(--toggle-bar-height) + 32px) 24px 32px;
    background: var(--color-sidebar);
    color: var(--color-on-dark);
    overflow-y: auto;
    z-index: 100;
    animation: fadeIn .5s both;
}

.site-header::-webkit-scrollbar { display: none; }
.site-header { scrollbar-width: none; }
.site-header[hidden] { display: none; }

/* Collapsing the panel hands its width back to the content column. */
body.sidebar-collapsed { --sidebar-width: 0px; }

.site-branding {
    padding-bottom: 24px;
    margin-bottom: 24px;
    border-bottom: 4px solid rgba(255, 255, 255, .08);
}

.site-title {
    font-family: var(--font-heading);
    font-size: 22px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -.5px;
    text-transform: uppercase;
    color: var(--color-on-dark-active);
    margin: 0 0 10px;
}

.site-description {
    font-size: 14px;
    line-height: 1.4;
    color: var(--color-on-dark);
    margin: 0;
}

/* Slot for logo_tcms.png (renders 228x65) when the asset is added. */
.site-logo { display: block; max-width: 100%; height: auto; margin-bottom: 18px; }

.panel { animation: fadeIn .2s both; }

.panel-title {
    font-family: var(--font-heading);
    font-size: var(--size-nav);
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--color-on-dark-active);
    margin: 0 0 14px;
}

.rule-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.rule-list li {
    display: flex;
    gap: 10px;
    padding: 9px 0;
    font-size: 15px;
    line-height: 1.4;
    border-top: 1px solid rgba(255, 255, 255, .07);
}

.rule-list li:first-child { border-top: 0; }

.rule-list b {
    flex: none;
    min-width: 22px;
    font-weight: 700;
    color: var(--color-on-dark-active);
}

/* The global code chip is a light plaque — on the dark panel that would be
   near-invisible, so invert it here. */
.site-header code {
    background: rgba(255, 255, 255, .09);
    color: var(--color-on-dark-active);
}

/* ---------------------------------------------------------- 4.0 Content */

.site-content {
    padding: 48px var(--content-gap) 32px
             calc(var(--sidebar-width) + var(--content-gap));
    padding-top: calc(var(--toggle-bar-height) + 32px);
}

.content-area {
    max-width: var(--content-max);
    animation: fadeIn .2s both;
}

/* Journal identity plaque — present on every page of the live site. */
.site-info-top {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--color-surface-alt);
    padding: 22px 24px;
}

.site-info-top .mark {
    flex: none;
    width: 38px; height: 50px;
    display: grid;
    place-items: center;
    background: var(--color-sidebar);
    color: #fff;
    font-family: var(--font-heading);
    font-size: 8px;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

.site-info-top h4 { margin: 0; line-height: 1.25; }
.site-info-top .issn { margin-left: auto; text-align: right; line-height: 1.4; }

.entry-content { max-width: var(--measure); margin-top: 30px; }
.entry-content .lead { color: var(--color-text-meta); font-size: 17px; }

hr.rule {
    height: 2px;
    border: 0;
    background: var(--color-divider);
    margin: 32px 0;
}

/* ------------------------------------------------------------- 5.0 Forms */

.form-section { margin-bottom: 34px; }

.form-section > .meta {
    display: block;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 4px solid var(--color-divider-strong);
}

/* File drop plaque */
.dropzone {
    display: flex;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
    background: var(--color-surface-alt);
    border: 2px solid var(--color-divider-strong);
    padding: 20px 22px;
    transition: border-color var(--transition), background var(--transition);
}

.dropzone.is-dragover {
    border-color: var(--color-accent);
    background: var(--color-surface);
}

.dropzone input[type="file"] { display: none; }

.file-name {
    font-size: 16px;
    color: var(--color-text-meta);
    word-break: break-all;
}

.file-name.has-file { color: var(--color-text); }

.author-row {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 10px;
    margin-bottom: 10px;
    animation: fadeIn .2s both;
}

input[type="text"],
input[type="password"] {
    width: 100%;
    font-family: var(--font-body);
    font-size: 16px;
    color: var(--color-text);
    background: var(--color-surface);
    border: 1px solid var(--color-field-border);
    border-radius: var(--radius-sm);
    padding: 11px 12px;
    transition: border-color var(--transition);
}

input[type="text"]:hover,
input[type="password"]:hover { border-color: #BBB; }
input[type="text"]:focus,
input[type="password"]:focus { border-color: var(--color-accent); }
input[type="text"]::placeholder { color: #AAA; }

/* Labelled field, stacked. Used by the login form. */
.field { margin-bottom: 20px; }
.field > .meta { display: block; margin-bottom: 7px; }

button,
.button {
    font-family: var(--font-heading);
    font-size: var(--size-button);
    letter-spacing: 1px;
    text-transform: uppercase;
    color: #fff;
    background: var(--color-text);
    border: none;
    border-radius: var(--radius-sm);
    padding: 12px 15px;
    cursor: pointer;
    transition: background var(--transition), color var(--transition),
                border-color var(--transition);
}

button:hover:not(:disabled) { background: #555; }

button:disabled {
    background: var(--color-divider-strong);
    color: #AAA;
    cursor: not-allowed;
}

button.ghost {
    background: none;
    color: var(--color-text);
    border: 1px solid var(--color-field-border);
    padding: 11px 14px;
}

button.ghost:hover:not(:disabled) {
    background: none;
    border-color: var(--color-text);
}

button.ghost:disabled { background: none; color: #BBB; border-color: var(--color-divider-strong); }

button.small { font-size: 13px; padding: 11px 12px; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* ------------------------------------------------------------ 6.0 Result */

#result[hidden] { display: none; }
#result { animation: fadeIn .2s both; }

.status {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    border-left: 6px solid var(--color-divider-strong);
    background: var(--color-surface-alt);
    padding: 18px 22px;
    margin-bottom: 26px;
}

.status .status-body { flex: 1; }
.status .status-headline { font-size: 20px; font-weight: 700; margin: 0 0 4px; }
.status .status-detail { margin: 0; font-size: 16px; color: var(--color-text-meta); }

.status.is-pending { border-left-color: var(--color-accent); }
.status.is-pending .status-headline { animation: pulse 1.4s ease-in-out infinite; }

.status.is-ok {
    border-left-color: var(--color-ok);
    background: var(--color-ok-tint);
}
.status.is-ok .status-headline { color: var(--color-ok); }

.status.is-warn {
    border-left-color: var(--color-warn);
    background: var(--color-warn-tint);
}
.status.is-warn .status-headline { color: var(--color-warn); }

.status.is-error {
    border-left-color: var(--color-danger);
    background: var(--color-danger-tint);
}
.status.is-error .status-headline { color: var(--color-danger); }

/* Error catalogue — laid out like the journal's volume article listing. */
.errors-head {
    border-top: 4px solid var(--color-divider-strong);
    padding-top: 14px;
    margin-bottom: 4px;
}

.error-list { list-style: none; margin: 0; padding: 0; }

.error-list li {
    display: flex;
    gap: 14px;
    align-items: baseline;
    padding: 14px 0;
    border-top: 1px solid #F1F1F1;
}

.error-list li:first-child { border-top: 0; }

.error-list .rule-tag {
    flex: none;
    min-width: 62px;
    font-size: 12px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--color-accent);
    font-weight: 700;
}

.error-list .rule-tag.is-generic { color: var(--color-text-meta); }
.error-list .error-text { margin: 0; font-size: 17px; }

.error-list .error-text pre {
    font-family: var(--font-mono);
    font-size: 14px;
    line-height: 1.6;
    background: var(--color-surface-alt);
    padding: 14px 16px;
    margin: 10px 0 0;
    max-height: 260px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

/* ------------------------------------------------------------- 6.5 Login */

/* The login page keeps the shell — dark bar, identity plaque, footer — but
   drops the sidebar entirely, so the column has no offset to reserve. */
.login-page { --sidebar-width: 0px; }

.login-shell {
    display: flex;
    justify-content: center;
    padding: calc(var(--toggle-bar-height) + 60px) var(--content-gap) 40px;
}

.login-card {
    width: 100%;
    max-width: 560px;
    animation: fadeIn .2s both;
}

/* The plaque is the card's masthead here, so it carries the full width and
   the ISSN line is dropped — nothing to balance it against. */
.login-card .entry-content { max-width: none; }
.login-card .status { margin-bottom: 24px; }

/* ------------------------------------------------------------ 7.0 Footer */

.site-footer {
    padding: 0 var(--content-gap) 40px
             calc(var(--sidebar-width) + var(--content-gap));
}

.site-footer .site-info {
    background: var(--color-surface-alt);
    padding: 22px 24px;
    font-size: var(--size-meta);
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--color-text-meta);
}

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

/* -------------------------------------------------------- 8.0 Animation */

@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes pulse  { 0%, 100% { opacity: 1 } 50% { opacity: .45 } }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
    }
}

/* ------------------------------------------------------ 9.0 Responsive */

@media (max-width: 768px) {
    :root { --size-body: 17px; --size-h1: 26px; --content-gap: 22px; }

    /* audit 12.2#10: the sidebar must not consume the first screen. */
    .site-header {
        position: relative;
        width: 100%;
        height: auto;
        max-width: none;
        padding: 24px 22px;
        margin-top: var(--toggle-bar-height);
    }

    .site-content,
    .site-footer { padding-left: var(--content-gap); }
    .site-content { padding-top: 28px; }

    .toggle-bar { padding: 8px 14px 0; }
    .toggle-bar .session span { display: none; }

    .login-shell { padding-top: calc(var(--toggle-bar-height) + 28px); }

    .author-row { grid-template-columns: 1fr 1fr; }
    .author-row button { grid-column: 2; justify-self: end; }

    .site-info-top { flex-wrap: wrap; }
    .site-info-top .issn { margin-left: 0; text-align: left; width: 100%; }

    .error-list li { flex-direction: column; gap: 4px; }
}
