/* Apple-inspired Wordle Clone - Simplified 2-Column Layout */

/* CSS Custom Properties */
:root {
  --bg-primary: #f5f5f7;
  --bg-secondary: #ffffff;
  --panel: #ffffff;
  --text-primary: #1d1d1f;
  --text-secondary: #86868b;
  --border-light: #d2d2d7;
  --shadow-light: rgba(0, 0, 0, 0.1);
  --shadow-md: rgba(0, 0, 0, 0.15);
  --shadow-heavy: rgba(0, 0, 0, 0.25);
  
  /* Game colors */
  --correct: #4fae5c;
  --present: #d1b24e;
  --absent: #3a3f47;
  --key-bg: #f2f2f7;
  --key-hover: #e5e5ea;
  
  /* Dark mode colors */
  --bg-primary-dark: #1c1c1e;
  --bg-secondary-dark: #2c2c2e;
  --panel-dark: #2c2c2e;
  --text-primary-dark: #ffffff;
  --text-secondary-dark: #8e8e93;
  --border-dark: #38383a;
  --key-bg-dark: #3a3a3c;
  --key-hover-dark: #48484a;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-primary: var(--bg-primary-dark);
    --bg-secondary: var(--bg-secondary-dark);
    --panel: var(--panel-dark);
    --text-primary: var(--text-primary-dark);
    --text-secondary: var(--text-secondary-dark);
    --border-light: var(--border-dark);
    --key-bg: var(--key-bg-dark);
    --key-hover: var(--key-hover-dark);
  }
}

/* Base styling */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', Arial, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "kern" 1;
}

/* Layout with Top Logo + 2-Column Grid */
#app-shell {
  display: grid;
  grid-template-rows: auto 1fr;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  padding: 48px;
  height: 100vh;
  width: 100vw;
  margin: 0;
  overflow: hidden;
  box-sizing: border-box;
}

/* Top Center Logo */
.logo-header {
  grid-column: 1 / -1;
  grid-row: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 0;
  padding: 0 0 0px 0;
}

.logo {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 0;
}

.logo-tile {
  width: 80px;
  height: 80px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  font-weight: 700;
  color: white;
  box-shadow: 0 4px 12px var(--shadow-light);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.logo-tile:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px var(--shadow-md);
}

.logo-tile.correct {
  background-color: var(--correct);
}

.logo-tile.present {
  background-color: var(--present);
}

/* Left Column: Status + Keyboard */
#left-column {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
  width: 100%;
  grid-column: 1;
  grid-row: 2;
  justify-content: flex-start;
  align-items: stretch;
  padding-top: 40px;
}

/* Status Panel */
#status-card {
  background-color: var(--panel);
  border-radius: 16px;
  padding: 12px;
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(255, 255, 255, 0.06);
  flex: 0 0 auto;
  height: 368px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  margin-left: 75px;
}

#status-card h3 {
  margin: 0 0 8px 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: center;
}

#status-chips {
  margin-bottom: 8px;
  min-height: 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: center;
  align-items: center;
}

#status-sub {
  margin: 0;
  font-size: 14px;
  color: var(--text-secondary);
  text-align: center;
  font-weight: 500;
}

/* Play again button in status bar */
#status-card #restart {
  margin-top: 8px;
  margin-bottom: 8px;
  padding: 6px 12px;
  background-color: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  align-self: center;
}

#status-card #restart:hover {
  background-color: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(79, 174, 92, 0.3);
}

#status-card #restart:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(79, 174, 92, 0.2);
}

/* Status chips */
.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  color: white;
  text-transform: uppercase;
  box-shadow: 0 1px 3px var(--shadow-light);
  margin: 1px;
}

.chip.correct {
  background-color: var(--correct);
}

.chip.present {
  background-color: var(--present);
}

.chip.absent {
  background-color: var(--absent);
}

/* Keyboard Card */
#kb-card {
  background-color: var(--panel);
  border-radius: 16px;
  padding: 16px;
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(255, 255, 255, 0.06);
  flex: 0 0 auto;
  height: 200px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  margin-left: 75px;
}

/* Keyboard */
#keyboard {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  justify-content: center;
}

.kb-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
  flex-wrap: nowrap;
}

.key {
  height: 60px;
  min-width: 44px;
  border: none;
  border-radius: 10px;
  background-color: var(--key-bg);
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 6px var(--shadow-light);
  display: flex;
  align-items: center;
  justify-content: center;
}

.key:hover {
  background-color: var(--key-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px var(--shadow-md);
}

.key:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px var(--shadow-light);
}

/* Special keys */
.key-enter,
.key-backspace {
  min-width: 80px;
}

/* Key feedback states */
.key.correct {
  background-color: var(--correct);
  color: white;
  box-shadow: 0 2px 8px rgba(79, 174, 92, 0.3);
}

.key.present {
  background-color: var(--present);
  color: white;
  box-shadow: 0 2px 8px rgba(209, 178, 78, 0.3);
}

.key.absent {
  background-color: var(--absent);
  color: white;
  box-shadow: 0 2px 8px rgba(58, 63, 71, 0.3);
}

/* Right Column: Board */
#right-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  height: 100%;
  width: 100%;
  gap: 20px;
  grid-column: 2;
  grid-row: 2;
  padding-top: 0;
}


/* Message styling */
#message {
  height: 24px;
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Game board */
#board {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(6, 1fr);
  gap: 12px;
  justify-content: center;
  margin: 0;
  width: 100%;
  max-width: 480px;
  aspect-ratio: 5/6;
}

/* Individual tile styling */
.tile {
  aspect-ratio: 1;
  border: 2px solid var(--border-light);
  border-radius: 12px;
  background-color: var(--bg-secondary);
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 32px;
  font-weight: 700;
  text-transform: uppercase;
  user-select: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 6px var(--shadow-light);
  position: relative;
  transform-style: preserve-3d;
}

.tile:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px var(--shadow-md);
}

/* Flip animation for tile reveals */
@keyframes flip {
  0% {
    transform: rotateX(0);
  }
  50% {
    transform: rotateX(-90deg);
  }
  100% {
    transform: rotateX(0);
  }
}

.tile.flip {
  animation: flip 0.6s ease-in-out;
}

/* Tile feedback states */
.tile.correct {
  background-color: var(--correct);
  border-color: var(--correct);
  color: white;
  box-shadow: 0 2px 8px rgba(79, 174, 92, 0.3);
}

.tile.present {
  background-color: var(--present);
  border-color: var(--present);
  color: white;
  box-shadow: 0 2px 8px rgba(209, 178, 78, 0.3);
}

.tile.absent {
  background-color: var(--absent);
  border-color: var(--absent);
  color: white;
  box-shadow: 0 2px 8px rgba(58, 63, 71, 0.3);
}

/* Restart button */
#restart {
  margin: 0;
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 600;
  background-color: var(--correct);
  color: white;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 8px rgba(79, 174, 92, 0.3);
}

#restart:hover {
  background-color: #45a050;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(79, 174, 92, 0.4);
}

#restart:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(79, 174, 92, 0.3);
}

/* Responsive Design */
@media (max-width: 768px) {
  #app-shell {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 16px;
    height: 100vh;
    overflow: hidden;
  }
  
  #left-column {
    order: 1;
    flex-direction: row;
    gap: 12px;
    flex: 0 0 auto;
  }
  
  #status-card {
    flex: 1;
    padding: 16px;
  }
  
  #kb-card {
    flex: 1;
    padding: 12px;
  }
  
  #right-column {
    order: 2;
    flex: 1;
    gap: 16px;
  }
  
  .key {
    height: 50px;
    min-width: 36px;
    font-size: 14px;
  }
  
  .key-enter,
  .key-backspace {
    min-width: 70px;
  }
  
  #board {
    max-width: 320px;
    gap: 8px;
  }
  
  .tile {
    font-size: 24px;
  }
  
  .logo-tile {
    width: 48px;
    height: 48px;
    font-size: 24px;
  }
}

@media (max-width: 480px) {
  #app-shell {
    padding: 12px;
    gap: 12px;
  }
  
  #left-column {
    flex-direction: column;
    gap: 8px;
  }
  
  #status-card,
  #kb-card {
    padding: 12px;
  }
  
  #board {
    max-width: 280px;
    gap: 6px;
  }
  
  .tile {
    font-size: 20px;
  }
  
  .logo-tile {
    width: 40px;
    height: 40px;
    font-size: 20px;
  }
  
  .key {
    height: 44px;
    min-width: 32px;
    font-size: 12px;
  }
  
  .key-enter,
  .key-backspace {
    min-width: 60px;
  }
}

/* Focus states for accessibility */
.key:focus-visible,
#restart:focus-visible {
  outline: 2px solid var(--correct);
  outline-offset: 2px;
}

/* Smooth transitions for theme changes */
* {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}