/* =================================================
   Alisa Avduli
   Date: October 2026
   Introduction to Web Design and Computer Principles
   NYU London - Fall 2026
   Project description: Assignment 07 - Form, Fonts, CSS & Accessibility
   (builds on grid.css from Assignment 06)
   ================================================= */

/* ===== 1. Self-hosted fonts (@font-face) =====
   Document-relative paths: these are resolved from THIS file (css/form.css),
   so ../fonts/ works wherever the site is hosted. */
@font-face {
    font-family: "OpenSansLocal";
    src: url("../fonts/open-sans-regular.woff2") format("woff2");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "OpenSansLocal";
    src: url("../fonts/open-sans-bold.woff2") format("woff2");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

/* ===== 2. Colour palette: CSS variables (light theme) ===== */
:root {
    --bg: #ffffff;
    --text: #1F2933;
    --muted: #4B5563;
    --header-bg: #0B5563;       /* header + footer */
    --heading: #0B5563;         /* h3, card titles, legends */
    --surface: #E6F4F1;         /* sidebar, even cards, fieldsets */
    --border: #0B5563;
    --field-border: #5F6B76;
    --accent: #E4572E;
    --link: #0B5563;
    --focus: #1A5FD0;
    --btn-bg: #0B5563;
    --btn-text: #ffffff;
    --btn-hover: #083F4A;
}

/* ===== 3. System dark mode: only the variable values change ===== */
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #121212;
        --text: #F1F1F1;
        --muted: #C4CCD1;
        --header-bg: #083C46;
        --heading: #7FD6CC;
        --surface: #1C2A2C;
        --border: #7FD6CC;
        --field-border: #9AA5AD;
        --accent: #FF8A65;
        --link: #7FD6CC;
        --focus: #FFD34D;
        --btn-bg: #7FD6CC;
        --btn-text: #0B1F22;
        --btn-hover: #A6E6DF;
    }
}

/* ===== 4. Modern CSS reset ===== */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    line-height: 1.5;
}

img, picture, svg, video {
    display: block;
    max-width: 100%;
    height: auto;
}

/* ===== 5. Outer grid: page skeleton with named areas ===== */
body {
    display: grid;
    min-height: 100vh;
    grid-template-rows: auto 1fr auto;
    grid-template-areas:
        "header"
        "main"
        "footer";
    font-family: "OpenSansLocal", Helvetica, Arial, sans-serif;
    font-size: 1rem;
    color: var(--text);
    background-color: var(--bg);
}

header { grid-area: header; }
main   { grid-area: main; }
footer { grid-area: footer; }

/* ===== 6. Skip links: hidden until they receive keyboard focus ===== */
.skip-link {
    position: absolute;
    top: 0;
    left: 0.5rem;
    z-index: 100;
    padding: 0.75rem 1rem;
    font-weight: bold;
    color: var(--btn-text);
    background-color: var(--btn-bg);
    border-radius: 0 0 4px 4px;
    transform: translateY(-150%);
}

.skip-link:focus {
    transform: translateY(0);
}

/* ===== 7. Visible focus states for all interactive elements ===== */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

/* ===== 8. Inner grid: mobile-first single column ===== */
main {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
        "hero"
        "main-content"
        "sidebar";
    align-content: start;
    gap: 1.5rem;
}

main > figure  { grid-area: hero; }
main > article { grid-area: main-content; }
main > aside   { grid-area: sidebar; }

/* ===== 9. Header & navigation (Flexbox) ===== */
header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1rem;
    padding: 1rem 1.5rem;
    background-color: var(--header-bg);
    color: #ffffff;
}

header > h1 {
    flex: 1;
    margin: 0;
    font-size: 1.5rem;
    line-height: 1.2;
}

header > nav {
    flex-basis: 100%;
}

nav > ul {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
    margin: 0;
    padding: 0;
    list-style: none;
}

nav > ul > li > a {
    display: inline-block;
    min-height: 44px;
    padding: 0.625rem 0.75rem;
    font-weight: bold;
    text-decoration: none;
    border-radius: 4px;
}

/* Link states in LVHA order */
nav a:link {
    color: #ffffff;
}

nav a:visited {
    color: #ffffff;
}

nav a:hover {
    color: #1F2933;
    background-color: #E6F4F1;
}

nav a:focus,
nav a:active {
    color: #1F2933;
    background-color: #E6F4F1;
    outline: 2px solid #ffffff;
}

/* Attribute selector: marks the page you are on */
nav a[aria-current="page"] {
    border-bottom: 3px solid var(--accent);
    border-radius: 0;
}

/* ===== 10. Inline SVG logo (colours come from CSS) ===== */
header > a {
    flex: none;
    display: block;
    line-height: 0;
    border-radius: 4px;
}

header > a:focus-visible {
    outline: 3px solid #ffffff;
    outline-offset: 2px;
}

header svg {
    width: 56px;
    height: 56px;
}

header svg circle {
    fill: none;
    stroke: #DC241F;
    stroke-width: 20px;
    transition: stroke-width 0.2s ease;
}

header svg rect {
    fill: #0019A8;
}

header svg text {
    fill: #ffffff;
    font-family: Arial, Helvetica, sans-serif;
    font-weight: bold;
    font-size: 24px;
    text-anchor: middle;
    dominant-baseline: middle;
}

header > a:hover svg circle,
header > a:focus svg circle {
    stroke-width: 26px;
}

/* ===== 11. Hero image (Flexbox centers it on one axis) =====
   The illustration has a transparent background, so the panel stays light
   in both themes to keep it readable. */
main > figure {
    display: flex;
    justify-content: center;
    margin: 0;
    padding: 1.5rem 1rem;
    background-color: #E6F4F1;
}

main > figure img {
    width: 100%;
    max-width: 240px;
}

/* ===== 12. Article text: child combinators & structural pseudo-classes ===== */
main > article {
    padding: 0 1.5rem;
}

article > h2 {
    margin: 0 0 1rem;
    font-size: 2rem;
    line-height: 1.2;
}

article > h2:first-child {
    margin-top: 0;
}

article > p {
    max-width: 65ch;
}

/* Lead paragraph: first direct paragraph of the main article */
main > article > p:first-of-type {
    padding-left: 1rem;
    border-left: 4px solid var(--accent);
    font-size: 1.25rem;
    font-weight: bold;
}

main a:link,
main a:visited {
    color: var(--link);
}

/* ===== 13. Nested auto-fit grid for the cards on the Response page ===== */
article > div {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

article > div > article {
    padding: 1rem 1.25rem;
    border: 2px solid var(--border);
    border-radius: 0.5rem;
}

article > div > article:nth-child(even) {
    background-color: var(--surface);
}

article > div > article > h3 {
    margin-top: 0;
    color: var(--heading);
}

/* ===== 14. Sidebar ===== */
main > aside {
    margin: 0 1.5rem 1.5rem;
    padding: 1.25rem 1.5rem;
    background-color: var(--surface);
    border-radius: 0.5rem;
}

aside > h3 {
    margin: 0 0 0.5rem;
    font-size: 1.25rem;
    color: var(--heading);
}

aside > h3:first-child {
    margin-top: 0;
}

aside > ul {
    margin: 0;
    padding-left: 1.25rem;
}

/* ===== 15. Form ===== */
form {
    max-width: 48rem;
}

fieldset {
    margin: 0 0 1.5rem;
    padding: 1rem 1.25rem;
    border: 2px solid var(--border);
    border-radius: 0.5rem;
    background-color: var(--surface);
}

legend {
    padding: 0 0.5rem;
    font-weight: bold;
    color: var(--heading);
}

/* Form rows: one column on mobile, label + control on desktop */
.form-row {
    display: grid;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.row-label {
    font-weight: normal;
}

input[type="text"],
input[type="email"],
input[type="url"],
input[type="number"],
select,
textarea {
    width: 100%;
    min-height: 44px;
    padding: 12px;
    border: 2px solid var(--field-border);
    border-radius: 4px;
    background-color: var(--bg);
    color: var(--text);
    font-family: inherit;
    font-size: 1rem; /* 1rem stops iPhones auto-zooming */
}

input[type="number"] {
    max-width: 8rem;
}

textarea {
    resize: vertical;
}

::placeholder {
    color: var(--muted);
    opacity: 1;
}

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.radio-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 44px;
}

input[type="radio"],
input[type="checkbox"] {
    flex: none;
    width: 1.5rem;
    height: 1.5rem;
    margin: 0;
    accent-color: var(--btn-bg);
}

.hint {
    margin: 0.25rem 0 0;
    font-size: 0.875rem;
    color: var(--muted);
}

form h3 {
    margin: 0 0 0.25rem;
    color: var(--heading);
}

.policy {
    max-width: none;
    margin: 0 0 1rem;
    padding: 1rem;
    border-left: 4px solid var(--accent);
    background-color: var(--surface);
}

.consent {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-height: 44px;
    margin-bottom: 1rem;
}

button[type="submit"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-width: 44px;
    min-height: 44px;
    padding: 0.75rem 1.5rem;
    border: 2px solid var(--btn-bg);
    border-radius: 4px;
    background-color: var(--btn-bg);
    color: var(--btn-text);
    font-family: inherit;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
}

button[type="submit"]:hover {
    background-color: var(--btn-hover);
    border-color: var(--btn-hover);
}

button[type="submit"] svg {
    width: 1.25rem;
    height: 1.25rem;
}

/* ===== 16. Footer ===== */
footer {
    padding: 1rem 1.5rem;
    background-color: var(--header-bg);
    color: #ffffff;
    text-align: center;
}

footer > h3 {
    margin: 0 0 0.25rem;
}

footer > p {
    margin: 0.25rem 0;
    font-size: 0.875rem;
}

footer > p:last-child {
    font-style: italic;
}

/* ===== 17. Desktop: inner grid becomes two columns ===== */
@media (min-width: 768px) {
    header {
        padding: 1.25rem 3rem;
    }

    header > h1 {
        font-size: 1.75rem;
    }

    header > nav {
        flex-basis: auto;
    }

    nav > ul {
        justify-content: flex-end;
    }

    main {
        grid-template-columns: 2fr 1fr;
        grid-template-areas:
            "hero hero"
            "main-content sidebar";
        gap: 2rem;
    }

    main > article {
        padding: 0 0 2rem 3rem;
    }

    main > aside {
        align-self: start;
        margin: 0 3rem 2rem 0;
    }

    .form-row {
        grid-template-columns: 11rem minmax(0, 1fr);
        align-items: start;
    }

    .radio-group {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.25rem 1.5rem;
    }
}
