/*
 * R&A Booking Widget - booking.css
 *
 * Design tokens resolve against the Client Center's brand.css (the single
 * source of truth for R&A brand values). Each alias below reads the canonical
 * variable and falls back to its literal value, so this file renders correctly
 * whether or not brand.css is loaded - and automatically follows any future
 * brand.css change when it is.
 *
 * Canonical tokens: --accent #8e191c, --text #181818, --border #e7e3dd,
 * --r 10px, --font 'Quattrocento Sans', --display 'DM Serif Display'.
 *
 * All selectors are scoped under .ra-booking to avoid conflicting with
 * WordPress or any parent page styles.
 */

/* -------------------------------------------------------------------------
   Token layer - aliases onto brand.css, with standalone fallbacks
   ------------------------------------------------------------------------- */
:root {
    /* Brand accent (R&A red) */
    --ra-accent:      var(--accent,     #8e191c);
    --ra-accent-dim:  var(--accent-dim, #6f1316);
    --ra-accent-bg:   var(--accent-bg,  rgba(142, 25, 28, .06));

    /* Surfaces */
    --ra-bg:          var(--bg,        #ffffff);
    --ra-surface:     var(--surface,   #ffffff);
    --ra-surface-2:   var(--surface-2, #f9f9f9);
    --ra-surface-3:   var(--surface-3, #f1efea);

    /* Lines */
    --ra-border:      var(--border,   #e7e3dd);
    --ra-border-2:    var(--border-2, #d8d2c8);

    /* Type colour */
    --ra-text:        var(--text,   #181818);
    --ra-text-2:      var(--text-2, #5b5b5b);
    --ra-text-3:      var(--text-3, #8a8a8a);

    /* Semantic */
    /* Semantic status colours. Gold (--star) is reserved for review stars in
       the portal and is deliberately not used here - the widget's statuses are
       success, neutral and urgency, not ratings. */
    --ra-error:       var(--danger,  #8e191c);
    --ra-error-bg:    var(--del-bg,  rgba(142, 25, 28, .10));
    --ra-success:     var(--ok-text, #1c7a44);
    --ra-success-bg:  var(--ok-bg,   rgba(28, 122, 68, .10));

    /* Shape and depth - R&A uses a single 10px radius */
    --ra-radius:      var(--r,  10px);
    --ra-radius-lg:   var(--r2, 10px);
    --ra-shadow:      var(--shadow, 0 1px 2px rgba(24, 24, 24, .04), 0 6px 18px rgba(24, 24, 24, .05));

    /* Type families */
    --ra-font-body:   var(--font,    'Quattrocento Sans', system-ui, -apple-system, sans-serif);
    --ra-font-serif:  var(--display, 'DM Serif Display', Georgia, serif);

    --ra-transition:  200ms ease;
}

/* -------------------------------------------------------------------------
   Widget shell
   ------------------------------------------------------------------------- */
.ra-booking {
    font-family:      var(--ra-font-body);
    font-size:        15px;
    line-height:      1.6;
    color:            var(--ra-text);
    background:       var(--ra-surface-2);
    min-height:       100vh;
    padding:          0;
    margin:           0;
    box-sizing:       border-box;
}

.ra-booking *,
.ra-booking *::before,
.ra-booking *::after {
    box-sizing: inherit;
}

/* -------------------------------------------------------------------------
   Header
   ------------------------------------------------------------------------- */
.ra-booking__header {
    background:    var(--ra-surface);
    color:         var(--ra-text);
    padding:       28px 32px 24px;
    text-align:    center;
    border-bottom: 3px solid var(--ra-accent);
}

.ra-booking__header h1 {
    margin:        0 0 4px;
    font-family:   var(--ra-font-serif);
    font-size:     22px;
    font-weight:   normal;
    letter-spacing: 0.03em;
    color:         var(--ra-text);
}

.ra-booking__header p {
    margin:     0;
    font-size:  13px;
    color:      var(--ra-text-2);
    letter-spacing: 0.02em;
}

/* -------------------------------------------------------------------------
   Step indicator
   ------------------------------------------------------------------------- */
.ra-steps {
    display:         flex;
    justify-content: center;
    align-items:     center;
    gap:             0;
    padding:         20px 32px 0;
    list-style:      none;
    margin:          0;
}

.ra-steps__item {
    display:     flex;
    align-items: center;
    font-size:   12px;
    font-weight: 500;
    color:       var(--ra-text-2);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.ra-steps__item--active {
    color: var(--ra-accent);
}

.ra-steps__item--done {
    color: var(--ra-success);
}

.ra-steps__num {
    width:         24px;
    height:        24px;
    border-radius: 50%;
    background:    var(--ra-border);
    color:         var(--ra-text-2);
    font-size:     11px;
    font-weight:   700;
    display:       inline-flex;
    align-items:   center;
    justify-content: center;
    margin-right:  7px;
    flex-shrink:   0;
    transition:    background var(--ra-transition), color var(--ra-transition);
}

.ra-steps__item--active .ra-steps__num {
    background: var(--ra-accent);
    color:      #fff;
}

.ra-steps__item--done .ra-steps__num {
    background: var(--ra-success);
    color:      #fff;
}

.ra-steps__divider {
    width:        32px;
    height:       1px;
    background:   var(--ra-border);
    margin:       0 8px;
    flex-shrink:  0;
}

/* -------------------------------------------------------------------------
   Main content area
   ------------------------------------------------------------------------- */
.ra-booking__main {
    max-width:  560px;
    margin:     0 auto;
    padding:    24px 24px 48px;
}

/* -------------------------------------------------------------------------
   Panel (each step lives in one)
   ------------------------------------------------------------------------- */
.ra-panel {
    background:    #fff;
    border:        1px solid var(--ra-border);
    border-radius: var(--ra-radius-lg);
    box-shadow:    var(--ra-shadow);
    overflow:      hidden;
    margin-bottom: 16px;
}

.ra-panel__head {
    padding:       18px 24px 14px;
    border-bottom: 1px solid var(--ra-border);
}

.ra-panel__head h2 {
    margin:        0;
    font-family:   var(--ra-font-serif);
    font-size:     17px;
    font-weight:   normal;
    color:         var(--ra-accent);
    letter-spacing: 0.01em;
}

.ra-panel__head p {
    margin:    4px 0 0;
    font-size: 13px;
    color:     var(--ra-text-2);
}

.ra-panel__body {
    padding: 20px 24px;
}

/* -------------------------------------------------------------------------
   Week strip - date navigation
   ------------------------------------------------------------------------- */
.ra-week {
    display:         flex;
    align-items:     center;
    gap:             6px;
}

.ra-week__nav {
    flex-shrink:     0;
    width:           34px;
    height:          34px;
    border:          1px solid var(--ra-border);
    border-radius:   var(--ra-radius);
    background:      #fff;
    cursor:          pointer;
    display:         flex;
    align-items:     center;
    justify-content: center;
    color:           var(--ra-text);
    transition:      border-color var(--ra-transition), color var(--ra-transition),
                     background var(--ra-transition);
    padding:         0;
}

.ra-week__nav:hover:not(:disabled) {
    border-color: var(--ra-accent);
    color:        var(--ra-accent);
    background:   var(--ra-surface-2);
}

.ra-week__nav:disabled {
    opacity:  0.35;
    cursor:   not-allowed;
}

.ra-week__days {
    flex:    1;
    display: flex;
    gap:     4px;
}

.ra-week__day {
    flex:            1;
    display:         flex;
    flex-direction:  column;
    align-items:     center;
    padding:         8px 4px;
    border:          1px solid var(--ra-border);
    border-radius:   var(--ra-radius);
    cursor:          pointer;
    background:      #fff;
    transition:      border-color var(--ra-transition), background var(--ra-transition),
                     color var(--ra-transition);
    min-width:       0;
    line-height:     1.2;
}

.ra-week__day:hover:not(.ra-week__day--disabled):not(.ra-week__day--selected) {
    border-color: var(--ra-accent);
    background:   var(--ra-surface-2);
}

.ra-week__day--selected {
    background:   var(--ra-accent);
    border-color: var(--ra-accent);
    color:        #fff;
}

.ra-week__day--disabled {
    opacity: 0.38;
    cursor:  not-allowed;
    pointer-events: none;
}

/* "Today" is a wayfinding cue, not a status - keep it neutral so it does
   not compete with the green availability dot or the red selected state. */
.ra-week__day--today:not(.ra-week__day--selected) {
    border-color: var(--ra-text-3);
}

.ra-week__day-name {
    font-size:   10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    opacity:     0.7;
}

.ra-week__day--selected .ra-week__day-name {
    opacity: 0.85;
}

.ra-week__day-num {
    font-size:   16px;
    font-weight: 600;
    margin-top:  2px;
}

.ra-week__day-dot {
    width:         5px;
    height:        5px;
    border-radius: 50%;
    background:    var(--ra-success);
    margin-top:    4px;
    visibility:    hidden;
}

.ra-week__day--has-slots .ra-week__day-dot {
    visibility: visible;
}

.ra-week__day--selected .ra-week__day-dot {
    background: rgba(255, 255, 255, 0.6);
}

/* -------------------------------------------------------------------------
   Slot grid
   ------------------------------------------------------------------------- */
.ra-slots {
    margin-top: 16px;
}

.ra-slots__label {
    font-size:   12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color:       var(--ra-text-2);
    margin-bottom: 10px;
}

.ra-slots__grid {
    display:               grid;
    grid-template-columns: repeat(3, 1fr);
    gap:                   8px;
}

.ra-slot-btn {
    padding:       10px 6px;
    border:        1px solid var(--ra-border);
    border-radius: var(--ra-radius);
    background:    #fff;
    font-size:     13px;
    font-weight:   500;
    color:         var(--ra-accent);
    cursor:        pointer;
    text-align:    center;
    transition:    border-color var(--ra-transition), background var(--ra-transition),
                   color var(--ra-transition), transform 80ms ease;
    line-height:   1.2;
}

.ra-slot-btn:hover:not(.ra-slot-btn--selected) {
    border-color: var(--ra-accent);
    background:   var(--ra-surface-2);
}

.ra-slot-btn--selected {
    background:   var(--ra-accent);
    border-color: var(--ra-accent);
    color:        #fff;
    transform:    scale(1.02);
}

.ra-slot-btn:active {
    transform: scale(0.98);
}

/* Empty / loading / error states */
.ra-slots__empty {
    text-align:  center;
    padding:     24px 0 8px;
    color:       var(--ra-text-2);
    font-size:   14px;
}

.ra-slots__loading {
    display:     flex;
    align-items: center;
    justify-content: center;
    gap:         8px;
    padding:     24px 0 8px;
    color:       var(--ra-text-2);
    font-size:   14px;
}

/* -------------------------------------------------------------------------
   Spinner
   ------------------------------------------------------------------------- */
.ra-spinner {
    width:         18px;
    height:        18px;
    border:        2px solid var(--ra-border);
    border-top-color: var(--ra-accent);
    border-radius: 50%;
    animation:     ra-spin 0.7s linear infinite;
    flex-shrink:   0;
}

@keyframes ra-spin {
    to { transform: rotate(360deg); }
}

/* -------------------------------------------------------------------------
   Booking form
   ------------------------------------------------------------------------- */
.ra-form {
    display:        flex;
    flex-direction: column;
    gap:            16px;
}

.ra-field {
    display:        flex;
    flex-direction: column;
    gap:            5px;
}

.ra-field label {
    font-size:   13px;
    font-weight: 600;
    color:       var(--ra-accent);
    letter-spacing: 0.01em;
}

.ra-field label .ra-required {
    color:       var(--ra-error);
    margin-left: 2px;
}

.ra-field input,
.ra-field textarea {
    width:         100%;
    padding:       10px 12px;
    border:        1px solid var(--ra-border);
    border-radius: var(--ra-radius);
    font-family:   var(--ra-font-body);
    font-size:     14px;
    color:         var(--ra-text);
    background:    #fff;
    transition:    border-color var(--ra-transition), box-shadow var(--ra-transition);
    outline:       none;
    -webkit-appearance: none;
    appearance:    none;
}

.ra-field input:focus,
.ra-field textarea:focus {
    border-color: var(--ra-accent);
    box-shadow:   0 0 0 3px rgba(142, 25, 28, 0.10);
}

.ra-field--error input,
.ra-field--error textarea {
    border-color: var(--ra-error);
}

.ra-field__error {
    font-size:  12px;
    color:      var(--ra-error);
    display:    none;
}

.ra-field--error .ra-field__error {
    display: block;
}

.ra-field textarea {
    resize:     vertical;
    min-height: 90px;
}

/* Honeypot - hidden from humans, visible to bots */
.ra-honeypot {
    position:   absolute;
    left:       -9999px;
    top:        -9999px;
    opacity:    0;
    height:     0;
    overflow:   hidden;
    pointer-events: none;
}

/* -------------------------------------------------------------------------
   Appointment summary bar (shown above form)
   ------------------------------------------------------------------------- */
.ra-summary {
    display:       flex;
    align-items:   center;
    justify-content: space-between;
    background:    var(--ra-surface-2);
    border:        1px solid var(--ra-border);
    border-radius: var(--ra-radius);
    padding:       12px 16px;
    margin-bottom: 4px;
}

.ra-summary__time {
    font-size:   14px;
    font-weight: 600;
    color:       var(--ra-accent);
}

.ra-summary__date {
    font-size: 12px;
    color:     var(--ra-text-2);
    margin-top: 2px;
}

.ra-summary__change {
    font-size:       13px;
    color:           var(--ra-accent);
    background:      none;
    border:          none;
    cursor:          pointer;
    padding:         4px 0;
    text-decoration: underline;
    text-underline-offset: 2px;
    font-family:     var(--ra-font-body);
}

.ra-summary__change:hover {
    color: var(--ra-accent-dim);
}

/* -------------------------------------------------------------------------
   Submit button
   ------------------------------------------------------------------------- */
.ra-submit {
    width:         100%;
    padding:       14px 24px;
    background:    var(--ra-accent);
    color:         #fff;
    border:        none;
    border-radius: var(--ra-radius);
    font-family:   var(--ra-font-body);
    font-size:     15px;
    font-weight:   600;
    cursor:        pointer;
    transition:    background var(--ra-transition), transform 80ms ease;
    letter-spacing: 0.02em;
    display:       flex;
    align-items:   center;
    justify-content: center;
    gap:           10px;
    margin-top:    4px;
}

.ra-submit:hover:not(:disabled) {
    background: var(--ra-accent-dim);
}

.ra-submit:active:not(:disabled) {
    transform: scale(0.99);
}

.ra-submit:disabled {
    opacity: 0.65;
    cursor:  not-allowed;
}

.ra-submit .ra-spinner {
    border-color:     rgba(255,255,255,0.3);
    border-top-color: #fff;
    display:          none;
}

.ra-submit--loading .ra-spinner {
    display: block;
}

/* -------------------------------------------------------------------------
   Status screens (success / error / verifying)
   ------------------------------------------------------------------------- */
.ra-status {
    text-align: center;
    padding:    40px 24px 32px;
}

.ra-status__icon {
    width:         56px;
    height:        56px;
    border-radius: 50%;
    display:       inline-flex;
    align-items:   center;
    justify-content: center;
    margin-bottom: 20px;
    font-size:     26px;
}

.ra-status__icon--success {
    background: rgba(28,122,68,.10);
    color:      var(--ra-success);
}

.ra-status__icon--error {
    background: rgba(142,25,28,.08);
    color:      var(--ra-error);
}

.ra-status__icon--pending {
    background: var(--ra-surface-2);
    color:      var(--ra-accent);
}

.ra-status h2 {
    font-family:   var(--ra-font-serif);
    font-size:     20px;
    font-weight:   normal;
    color:         var(--ra-accent);
    margin:        0 0 10px;
}

.ra-status p {
    font-size:  14px;
    color:      var(--ra-text-2);
    margin:     0 0 8px;
    max-width:  360px;
    margin-left:  auto;
    margin-right: auto;
}

/* The hold countdown is genuinely time-critical - the slot is released when
   it reaches zero - so it carries the danger colour rather than an accent. */
.ra-status__timer {
    font-size:   13px;
    color:       var(--ra-error);
    font-weight: 600;
    margin-top:  8px;
}

.ra-status__back {
    margin-top:      20px;
    display:         inline-block;
    font-size:       13px;
    color:           var(--ra-accent);
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor:          pointer;
    background:      none;
    border:          none;
    font-family:     var(--ra-font-body);
    padding:         0;
}

/* -------------------------------------------------------------------------
   Alert banner
   ------------------------------------------------------------------------- */
.ra-alert {
    border-radius: var(--ra-radius);
    padding:       12px 16px;
    font-size:     13px;
    margin-bottom: 12px;
    display:       none;
}

.ra-alert--error {
    background: rgba(142,25,28,.08);
    color:      var(--ra-error);
    border:     1px solid rgba(142,25,28,.20);
    display:    block;
}

.ra-alert--info {
    background: #eaf0f9;
    color:      var(--ra-accent);
    border:     1px solid #c8d9ee;
    display:    block;
}

/* -------------------------------------------------------------------------
   Footer note
   ------------------------------------------------------------------------- */
.ra-booking__footer {
    text-align:  center;
    font-size:   12px;
    color:       var(--ra-text-2);
    padding:     0 24px 32px;
}

.ra-booking__footer a {
    color: var(--ra-accent);
}

/* -------------------------------------------------------------------------
   Transitions between steps
   ------------------------------------------------------------------------- */
.ra-panel {
    animation: ra-fade-up 220ms ease both;
}

@keyframes ra-fade-up {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.ra-slots__grid {
    animation: ra-fade 180ms ease both;
}

@keyframes ra-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
    .ra-panel,
    .ra-slots__grid,
    .ra-spinner {
        animation: none !important;
        transition: none !important;
    }
}

/* -------------------------------------------------------------------------
   Responsive
   ------------------------------------------------------------------------- */
@media (max-width: 480px) {
    .ra-booking__header {
        padding: 20px 16px 18px;
    }

    .ra-booking__main {
        padding: 16px 12px 40px;
    }

    .ra-panel__body {
        padding: 16px;
    }

    .ra-panel__head {
        padding: 14px 16px 12px;
    }

    .ra-week__day-name {
        font-size: 9px;
    }

    .ra-week__day-num {
        font-size: 14px;
    }

    .ra-steps {
        padding: 16px 16px 0;
    }

    .ra-slots__grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }

    .ra-slot-btn {
        font-size: 12px;
        padding:   9px 4px;
    }
}
