/* ============================================================
   Family Motors — stylesheet
   Palette: ink charcoal-navy, cool paper, white surfaces,
   heritage pine-green accent. Type: Plus Jakarta Sans.
   ============================================================ */

:root {
    --ink:        #1a1d21;
    --ink-soft:   #262a30;
    --paper:      #f4f5f6;
    --surface:    #ffffff;
    --line:       #e4e2db;
    --line-dark:  #33383f;
    --text:       #1a1d21;
    --muted:      #6b6e73;
    --muted-ink:  #a7adb5;
    --green:      #1f5c3d;
    --green-deep: #17452e;
    --green-tint: #eaf1ec;
    --amber:      #b6802b;
    --red:        #a23a30;

    --radius:     14px;
    --radius-sm:  9px;
    --shadow:     0 1px 2px rgba(26,29,33,.05), 0 12px 30px -18px rgba(26,29,33,.35);
    --wrap:       1180px;

    --font-head: 'Plus Jakarta Sans', system-ui, sans-serif;
    --font-body: 'Plus Jakarta Sans', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font-body);
    color: var(--text);
    background: var(--paper);
    line-height: 1.55;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }

img { display: block; max-width: 100%; }

h1, h2, h3 { font-family: var(--font-head); line-height: 1.08; margin: 0; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 24px; }

/* ---- Brand ------------------------------------------------- */
/* Speed-lines logo: silver slanted bars + italic chrome wordmark. */
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand__mark {
    width: 30px; height: 26px; flex-shrink: 0;
    background: url("../img/brand-speedlines.svg") center / contain no-repeat;
}
.brand__text { display: flex; flex-direction: column; gap: 3px; }
.brand__name {
    font-family: var(--font-head); font-weight: 800; font-style: italic;
    font-size: 1.25rem; letter-spacing: .01em; line-height: 1;
    text-transform: uppercase; white-space: nowrap;
    color: #e2e5e8; /* fallback if background-clip isn't supported */
    background: linear-gradient(180deg, #ffffff 0%, #e2e5e8 42%, #a9afb6 52%, #d7dade 70%, #f1f2f4 100%);
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent;
}
.brand__sub {
    font-family: var(--font-head); font-weight: 600; font-style: italic;
    font-size: .6rem; letter-spacing: .42em; line-height: 1;
    text-transform: uppercase; color: var(--muted-ink);
}

/* ---- Header ------------------------------------------------ */
.site-header { background: var(--ink); position: sticky; top: 0; z-index: 30; }
.site-header__inner {
    display: flex; align-items: center; justify-content: space-between;
    height: 68px;
}
.nav { display: flex; align-items: center; gap: 26px; }
.nav a { color: var(--muted-ink); font-weight: 500; font-size: .95rem; white-space: nowrap; }
.nav a:hover { color: #fff; text-decoration: none; }

/* ---- Hero -------------------------------------------------- */
/* .hero__inner uses the same .wrap width/padding as the header, so the
   title and photo line up with the brand logo above. */
.hero { background: var(--ink); color: #fff; }
.hero__inner { padding-top: 52px; padding-bottom: 74px; }
.hero__kicker {
    margin: 0 0 18px; color: var(--green);
    font-family: var(--font-head); font-weight: 600; font-size: .9rem;
    display: inline-flex; align-items: center; gap: 9px;
}
.hero__kicker::before {
    content: ""; width: 26px; height: 2px; background: var(--green);
}
.hero__title {
    font-size: clamp(1.2rem, 5vw, 1.5rem);
    font-weight: 800; letter-spacing: -.02em; color: #fff;
}
.hero__intro {
    display: flex; align-items: flex-start; gap: 28px;
    margin-top: 26px;
}
.hero__photo {
    width: 150px; height: auto; flex-shrink: 0;
    border-radius: var(--radius);
    border: 3px solid var(--ink-soft);
    box-shadow: 0 10px 30px -12px rgba(0,0,0,.6);
}
.hero__lead { margin: 0; max-width: 68ch; color: var(--muted-ink); font-size: 1.1rem; }
.hero__stock {
    margin: 30px 0 0; display: inline-flex; align-items: baseline; gap: 8px;
    color: #fff; background: var(--ink-soft);
    border: 1px solid var(--line-dark);
    padding: 12px 18px; border-radius: 999px; font-size: .98rem;
}
.hero__stock strong {
    font-family: var(--font-head); font-size: 1.35rem; color: var(--green);
}

/* ---- Listing bar ------------------------------------------- */
.listing { padding: 66px 24px 70px; }
.listing__bar {
    display: flex; align-items: flex-end; justify-content: space-between;
    gap: 20px; flex-wrap: wrap; margin-bottom: 26px;
}
.listing__heading { font-size: 1.6rem; font-weight: 700; letter-spacing: -.01em; }
.sortform { display: flex; align-items: center; gap: 10px; }
.sortform label { color: var(--muted); font-size: .9rem; }
.sortform select {
    font-family: var(--font-body); font-size: .95rem;
    padding: 9px 34px 9px 14px; border: 1px solid var(--line);
    border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
    appearance: none; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b6e73' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 13px center;
}
.sortform select:focus-visible { outline: 2px solid var(--green); outline-offset: 1px; }

/* ---- Car grid ---------------------------------------------- */
.grid {
    display: grid; gap: 22px;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
}
.card {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); overflow: hidden;
    color: var(--text); text-decoration: none;
    display: flex; flex-direction: column;
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.card:hover {
    text-decoration: none; transform: translateY(-3px);
    box-shadow: var(--shadow); border-color: #d4d2ca;
}
.card__photo { position: relative; aspect-ratio: 3 / 2; background: #eceae4; }
.card__photo img { width: 100%; height: 100%; object-fit: cover; }
.card__noimg {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    color: var(--muted); font-size: .9rem;
}
.card--sold .card__photo img { filter: grayscale(.55) brightness(.94); }
.card__body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 12px; }
.card__titlerow { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.card__title { font-size: 1.12rem; font-weight: 700; letter-spacing: -.01em; }
.card__price { font-family: var(--font-head); font-weight: 700; color: var(--green); font-size: 1.12rem; white-space: nowrap; }
.card__specs {
    list-style: none; margin: 0; padding: 0;
    display: flex; flex-wrap: wrap; gap: 7px;
}
.card__specs li {
    font-size: .82rem; color: var(--muted);
    background: var(--paper); border: 1px solid var(--line);
    padding: 3px 9px; border-radius: 999px;
}

/* ---- Status badges ----------------------------------------- */
.badge {
    position: absolute; top: 12px; left: 12px;
    font-family: var(--font-head); font-weight: 700; font-size: .72rem;
    padding: 5px 11px; border-radius: 999px; color: #fff;
    letter-spacing: .02em;
}
.badge--sold     { background: var(--red); }
.badge--reserved { background: var(--amber); }
.badge--lg { top: 16px; left: 16px; font-size: .85rem; padding: 7px 14px; }

/* ---- Empty state ------------------------------------------- */
.empty {
    background: var(--surface); border: 1px dashed var(--line);
    border-radius: var(--radius); padding: 54px 30px; text-align: center;
    color: var(--muted);
}
.empty p { margin: 0 0 8px; }

/* ---- Buttons ----------------------------------------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    font-family: var(--font-head); font-weight: 600; font-size: .96rem;
    padding: 12px 20px; border-radius: var(--radius-sm);
    background: var(--green); color: #fff; border: 1px solid var(--green);
    cursor: pointer; text-decoration: none; transition: background .15s ease;
}
.btn:hover { background: var(--green-deep); text-decoration: none; }
.btn--ghost { background: transparent; color: var(--green); }
.btn--ghost:hover { background: var(--green-tint); }
.btn--block { width: 100%; }
.btn--danger { background: var(--red); border-color: var(--red); }
.btn--danger:hover { background: #862f27; }
.btn--muted { background: var(--surface); color: var(--text); border-color: var(--line); }
.btn--muted:hover { background: var(--paper); }
.btn--sm { padding: 8px 14px; font-size: .88rem; }

/* ---- Car detail -------------------------------------------- */
.detail { padding: 30px 24px 72px; }
.backlink { display: inline-block; margin-bottom: 22px; color: var(--muted); font-weight: 500; }
.backlink:hover { color: var(--green); text-decoration: none; }
.detail__grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 34px; align-items: start; }

.gallery__main {
    position: relative; border-radius: var(--radius); overflow: hidden;
    background: #eceae4; aspect-ratio: 3 / 2;
}
.gallery__main img { width: 100%; height: 100%; object-fit: cover; }
.gallery__main--empty { display: flex; align-items: center; justify-content: center; color: var(--muted); }
.gallery__thumbs {
    display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-top: 12px;
}
.gallery__thumb {
    padding: 0; border: 2px solid transparent; border-radius: var(--radius-sm);
    overflow: hidden; cursor: pointer; background: #eceae4; aspect-ratio: 4 / 3;
}
.gallery__thumb img { width: 100%; height: 100%; object-fit: cover; }
.gallery__thumb.is-active { border-color: var(--green); }
.gallery__thumb:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

.specpanel {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 26px; position: sticky; top: 88px;
}
.specpanel__title { font-size: 1.5rem; font-weight: 700; letter-spacing: -.01em; }
.specpanel__sub { margin: 6px 0 0; color: var(--muted); }
.specpanel__price {
    font-family: var(--font-head); font-weight: 800; font-size: 2rem;
    color: var(--green); margin: 16px 0 20px;
}
.specpanel__list {
    display: grid; grid-template-columns: 1fr 1fr; gap: 1px;
    background: var(--line); border: 1px solid var(--line);
    border-radius: var(--radius-sm); overflow: hidden; margin: 0 0 22px;
}
.specpanel__list > div { background: var(--surface); padding: 11px 14px; }
.specpanel__list dt { color: var(--muted); font-size: .78rem; margin-bottom: 2px; }
.specpanel__list dd { margin: 0; font-weight: 600; font-size: .96rem; }
.specpanel__cta { display: flex; flex-direction: column; gap: 10px; }
.specpanel__note { margin: 0 0 4px; color: var(--muted); font-size: .92rem; }

.description { margin-top: 40px; max-width: 68ch; }
.description h2 { font-size: 1.35rem; font-weight: 700; margin-bottom: 12px; }
.description p { margin: 0 0 14px; }

/* ---- Footer ------------------------------------------------ */
.site-footer { background: var(--ink); color: var(--muted-ink); margin-top: auto; }
.site-footer__grid {
    display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 34px;
    padding: 54px 24px 34px;
}
.brand--footer .brand__name { font-size: 1.15rem; }
.site-footer__tag { margin: 14px 0 0; max-width: 34ch; }
.site-footer__col h3 { color: #fff; font-size: 1rem; font-weight: 600; margin-bottom: 12px; }
.site-footer__col p { margin: 0 0 6px; }
.site-footer a { color: #fff; }
.site-footer__base {
    border-top: 1px solid var(--line-dark); padding: 18px 24px;
    font-size: .85rem;
}

/* ============================================================
   Admin
   ============================================================ */
.admin-body { background: var(--paper); min-height: 100vh; display: flex; flex-direction: column; }

.admin-header { background: var(--ink); color: #fff; }
.admin-header__inner {
    display: flex; align-items: center; justify-content: space-between; height: 64px;
}
.admin-header__inner .brand__name { font-size: 1.1rem; }
.admin-nav { display: flex; align-items: center; gap: 20px; }
.admin-nav a { color: var(--muted-ink); font-size: .93rem; font-weight: 500; }
.admin-nav a:hover { color: #fff; text-decoration: none; }
.admin-nav .who { color: var(--muted-ink); font-size: .88rem; }
.admin-nav .who strong { color: #fff; }

.admin-main { flex: 1; padding: 38px 24px 70px; }

/* ---- Login ------------------------------------------------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--ink); }
.login-card {
    background: var(--surface); border-radius: var(--radius);
    padding: 40px 36px; width: 100%; max-width: 380px; box-shadow: var(--shadow);
}
.login-card .brand { margin-bottom: 26px; }
/* White card: switch the chrome to a dark gunmetal so it stays readable */
.login-card .brand__name {
    background: linear-gradient(180deg, #5b6168 0%, #2a2e33 55%, #1a1d21 100%);
    -webkit-background-clip: text; background-clip: text;
}
.login-card .brand__sub { color: var(--muted); }
.login-card .brand__mark { filter: brightness(.5) contrast(1.2); }
.login-card h1 { font-size: 1.4rem; font-weight: 700; margin-bottom: 6px; }
.login-card p.sub { color: var(--muted); margin: 0 0 24px; font-size: .95rem; }

/* ---- Forms ------------------------------------------------- */
.field { margin-bottom: 18px; }
.field label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
.field .hint { color: var(--muted); font-weight: 400; font-size: .82rem; }
.input, .textarea, .select {
    width: 100%; font-family: var(--font-body); font-size: .98rem;
    padding: 11px 13px; border: 1px solid var(--line); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--text);
}
.input:focus, .textarea:focus, .select:focus { outline: 2px solid var(--green); outline-offset: -1px; border-color: var(--green); }
.textarea { min-height: 140px; resize: vertical; line-height: 1.5; }
.select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b6e73' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 13px center;
}
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 20px; }
.form-grid .span-2 { grid-column: 1 / -1; }

/* ---- Flash messages ---------------------------------------- */
.flash { border-radius: var(--radius-sm); padding: 12px 16px; margin-bottom: 18px; font-size: .95rem; border: 1px solid; }
.flash--success { background: var(--green-tint); border-color: #bcd6c4; color: var(--green-deep); }
.flash--error   { background: #fbeceb; border-color: #edc9c5; color: #862f27; }

/* ---- Admin page heading ------------------------------------ */
.page-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px; flex-wrap: wrap; margin-bottom: 26px;
}
.page-head h1 { font-size: 1.7rem; font-weight: 700; letter-spacing: -.01em; }
.page-head .count { color: var(--muted); font-size: .95rem; }
.page-head .count strong { color: var(--text); }

/* ---- Admin table ------------------------------------------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 14px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-family: var(--font-head); font-size: .82rem; color: var(--muted); font-weight: 600; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--paper); }
.table__thumb { width: 74px; height: 52px; border-radius: 7px; object-fit: cover; background: #eceae4; }
.table__thumb--empty { display: flex; align-items: center; justify-content: center; font-size: .65rem; color: var(--muted); text-align: center; }
.table__car { font-weight: 600; }
.table__car small { display: block; color: var(--muted); font-weight: 400; font-size: .82rem; }
.table__actions { display: flex; gap: 8px; justify-content: flex-end; }

.pill { font-family: var(--font-head); font-size: .74rem; font-weight: 700; padding: 4px 10px; border-radius: 999px; }
.pill--available { background: var(--green-tint); color: var(--green-deep); }
.pill--reserved  { background: #f6ecd6; color: #7a5713; }
.pill--sold      { background: #fbeceb; color: #862f27; }

/* ---- Limit notice ------------------------------------------ */
.limit-note {
    background: #f6ecd6; border: 1px solid #e6d3a6; color: #7a5713;
    border-radius: var(--radius-sm); padding: 12px 16px; margin-bottom: 22px; font-size: .93rem;
}

/* ---- Existing images in edit form -------------------------- */
.imggrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; margin-top: 6px; }
.imgcard { position: relative; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: #eceae4; }
.imgcard img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.imgcard__photo { position: relative; }
.imgcard__tools {
    position: absolute; top: 6px; right: 6px; display: flex; gap: 5px;
}
.imgcard__rotate {
    width: 32px; height: 32px; padding: 0; border: none; border-radius: 999px;
    display: inline-flex; align-items: center; justify-content: center;
    background: rgba(26,29,33,.78); color: #fff; cursor: pointer;
    transition: background .15s ease;
}
.imgcard__rotate:hover { background: var(--ink); }
.imgcard__rotate:disabled { opacity: .5; cursor: wait; }
.imgcard.is-busy img { opacity: .45; }
.imgcard__bar { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px; background: var(--surface); font-size: .78rem; }
.imgcard__primary { color: var(--green); font-weight: 600; }
.imgcard__del { color: var(--red); background: none; border: none; cursor: pointer; font-size: .78rem; padding: 0; font-family: var(--font-body); }
.imgcard__del:hover { text-decoration: underline; }

.form-actions { display: flex; gap: 12px; margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--line); }

.filehint { font-size: .82rem; color: var(--muted); margin-top: 6px; }
input[type="file"] { font-family: var(--font-body); font-size: .92rem; }

/* ---- Responsive -------------------------------------------- */
@media (max-width: 820px) {
    .detail__grid { grid-template-columns: 1fr; gap: 24px; }
    .specpanel { position: static; }
    .site-footer__grid { grid-template-columns: 1fr; gap: 26px; }
    .gallery__thumbs { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 620px) {
    .nav { gap: 16px; }
    .nav a { font-size: .88rem; }
    .brand__name { font-size: 1.05rem; }
    .brand__sub { font-size: .52rem; }
    .form-grid { grid-template-columns: 1fr; }
    .hero__inner { padding-top: 46px; padding-bottom: 54px; }
    .hero__intro { gap: 16px; }
    .hero__photo { width: 96px; }
    .hero__lead { font-size: 1rem; }
    .table__hide-sm { display: none; }
}

/* ---- Mobile menu ------------------------------------------- */
/* Hamburger button on phones; the links drop down in a panel under the header.
   The panel only collapses once main.js adds .nav-ready, so without
   JavaScript the links simply stay visible in the header. */
.navtoggle { display: none; }

@media (max-width: 620px) {
    .navtoggle {
        display: inline-flex; align-items: center; justify-content: center;
        width: 44px; height: 44px; margin-right: -10px; padding: 0;
        border: 0; background: none; color: #fff; cursor: pointer;
    }
    .navtoggle__bars,
    .navtoggle__bars::before,
    .navtoggle__bars::after {
        display: block; width: 22px; height: 2px; border-radius: 2px;
        background: currentColor; transition: transform .2s ease, background .2s ease;
    }
    .navtoggle__bars { position: relative; }
    .navtoggle__bars::before,
    .navtoggle__bars::after { content: ""; position: absolute; left: 0; }
    .navtoggle__bars::before { top: -7px; }
    .navtoggle__bars::after  { top: 7px; }

    /* Turn the three bars into an X when open */
    .nav-open .navtoggle__bars { background: transparent; }
    .nav-open .navtoggle__bars::before { transform: translateY(7px) rotate(45deg); }
    .nav-open .navtoggle__bars::after  { transform: translateY(-7px) rotate(-45deg); }

    /* The drop-down panel */
    .site-header.nav-ready .nav {
        display: none; position: absolute; top: 100%; left: 0; right: 0;
        flex-direction: column; align-items: stretch; gap: 0;
        background: var(--ink); border-top: 1px solid var(--line-dark);
        padding: 6px 0 12px; box-shadow: 0 14px 24px -14px rgba(0,0,0,.6);
    }
    .site-header.nav-open .nav { display: flex; }
    .site-header.nav-ready .nav a { padding: 13px 24px; font-size: 1rem; color: #fff; }
    .site-header.nav-ready .nav a:hover { background: var(--ink-soft); }
}

#carslist { scroll-margin-top: 68px; }

/* ---- Photo watermark --------------------------------------- */
/* Speed-lines logo in the bottom-right of every car photo on the public site.
   Only shown when there's a real photo (not on "Photos coming soon"). */
.card__photo:has(img)::after,
.gallery__main:has(img)::after {
    content: "";
    position: absolute;
    right: 12px; bottom: 12px;
    width: 40px; aspect-ratio: 30 / 26;
    background: url("../img/brand-speedlines.svg") center / contain no-repeat;
    opacity: .85;
    /* Dark halo so the silver logo still shows on pale or white cars */
    filter: drop-shadow(0 1px 2px rgba(0,0,0,.6)) drop-shadow(0 0 6px rgba(0,0,0,.35));
    pointer-events: none;
    z-index: 1;
}
.gallery__main:has(img)::after { width: 64px; right: 18px; bottom: 18px; }

@media (max-width: 620px) {
    .gallery__main:has(img)::after { width: 48px; right: 14px; bottom: 14px; }
}

/* ---- Accessibility ----------------------------------------- */
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}
